From 6850084233f0067421270b5edbe45ecd2716dc08 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Apr 2022 18:00:23 +0000 Subject: [PATCH 001/108] Auto-generated commit 98c84b98ebdcca5937cc0a13c5831f2ad372370f --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 322 ++++++ index.d.ts | 217 ++++ index.mjs | 4 + index.mjs.map | 1 + package.json | 68 ++ stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3811 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..5fadf5e --- /dev/null +++ b/README.md @@ -0,0 +1,322 @@ + + +# Filled Array + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Create a filled array. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; +``` + +#### filledarray( \[dtype] ) + +Creates a filled array having a specified data type `dtype`. + +```javascript +var arr = filledarray(); +// 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 = filledarray( 'int32' ); +// returns +``` + +#### filledarray( value, length\[, dtype] ) + +Returns a filled array having a specified `length`. + +```javascript +var arr1 = filledarray( 1.0, 5 ); +// returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + +var arr2 = filledarray( 1, 5, 'uint8' ); +// returns [ 1, 1, 1, 1, 1 ] +``` + +#### filledarray( value, array\[, dtype] ) + +Creates a filled array from another array (or array-like object). + +```javascript +var arr0 = { + '0': 0.5, + '1': 0.5, + '2': 0.5, + 'length': 3 +}; + +var arr1 = filledarray( 1.0, arr0 ); +// returns [ 1.0, 1.0, 1.0 ] + +var arr2 = filledarray( 2.0, arr1 ); +// returns [ 2.0, 2.0, 2.0 ] + +var arr3 = filledarray( 3, arr1, 'int32' ); +// returns [ 3, 3, 3 ] +``` + +#### filledarray( value, iterable\[, dtype] ) + +Creates a filled array from an iterable. + +```javascript +import iterConstant from 'https://cdn.jsdelivr.net/gh/stdlib-js/iter-constant@esm/index.mjs'; + +var it = iterConstant( 3.0, { + 'iter': 3 +}); +var arr1 = filledarray( 1.0, it ); +// returns [ 1.0, 1.0, 1.0 ] + +var arr2 = filledarray( 1.0, it, 'float32' ); +// returns [ 1.0, 1.0, 1.0 ] +``` + +#### filledarray( value, buffer\[, byteOffset\[, length]]\[, dtype] ) + +Returns a filled [typed array][mdn-typed-array] view of an [`ArrayBuffer`][mdn-arraybuffer]. + +```javascript +import ArrayBuffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs'; + +var buf = new ArrayBuffer( 32 ); +var arr = filledarray( 1.0, buf ); +// returns [ 1.0, 1.0, 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1.0, buf, 'float32' ); +// returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1.0, buf, 16 ); +// returns [ 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1.0, buf, 16, 'float32' ); +// returns [ 1.0, 1.0, 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1.0, buf, 16, 1 ); +// returns [ 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1, buf, 10, 4, 'int16' ); +// returns [ 1, 1, 1, 1 ] +``` + +
+ + + + + +
+ +## Notes + +- Creating a generic [array][mdn-array] from an [`ArrayBuffer`][mdn-arraybuffer] is **not** supported. + +
+ + + + + +
+ +## 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..daebabf --- /dev/null +++ b/index.d.ts @@ -0,0 +1,217 @@ +/* +* @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. +*/ + +// 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; + +/** +* Creates a filled array. +* +* 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 (default: 'float64') +* @returns filled array +* +* @example +* var arr = filledarray(); +* // returns +* +* @example +* var arr = filledarray( 'float32' ); +* // returns +*/ +declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; + +/** +* Creates a filled array having a specified `length`. +* +* @param value - fill value +* @param length - array length +* @param dtype - data type (default: 'float64') +* @returns filled array +* +* @example +* var arr = filledarray( 1.0, 5 ); +* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +* +* @example +* var arr = filledarray( 1.0, 5, 'float32' ); +* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length + +/** +* Creates a filled array from another `array`. +* +* @param value - fill value +* @param array - typed array or array-like object +* @param dtype - data type (default: 'float64') +* @returns filled array +* +* @example +* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); +* // returns [ 1.0, 1.0, 1.0 ] +* +* @example +* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); +* // returns [ 1.0, 1.0, 1.0 ] +*/ +declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures + +/** +* Creates a filled array from an iterable. +* +* @param value - fill value +* @param iterable - iterable +* @param dtype - data type (default: 'float64') +* @returns filled array +* +* @example +* var iterConstant = require( `@stdlib/iter/constant` ); +* +* var it = iterConstant( 3.0, { +* 'iter': 3 +* }); +* var arr = filledarray( 1.0, it ); +* // returns [ 1.0, 1.0, 1.0 ] +* +* @example +* var iterConstant = require( `@stdlib/iter/constant` ); +* +* var it = iterConstant( 3.0, { +* 'iter': 3 +* }); +* var arr = filledarray( 1.0, it, 'float32' ); +* // returns [ 1.0, 1.0, 1.0 ] +*/ +declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures + +/** +* Returns a filled typed array view of an `ArrayBuffer`. +* +* ## Notes +* +* - Creating a generic array from an `ArrayBuffer` is **not** supported. +* +* @param value - fill value +* @param buffer - `ArrayBuffer` +* @param byteOffset - byte offset +* @param length - view length +* @param dtype - data type (default: 'float64') +* @returns filled array +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8, 2 ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); +* // returns [ 1.0, 1.0 ] +*/ +declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length + +/** +* Returns a filled typed array view of an `ArrayBuffer`. +* +* ## Notes +* +* - Creating a generic array from an `ArrayBuffer` is **not** supported. +* +* @param value - fill value +* @param buffer - `ArrayBuffer` +* @param byteOffset - byte offset +* @param dtype - data type (default: 'float64') +* @returns filled array +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8 ); +* // returns [ 1.0, 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8, 'float32' ); +* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length + +/** +* Returns a filled typed array view of an `ArrayBuffer`. +* +* ## Notes +* +* - Creating a generic array from an `ArrayBuffer` is **not** supported. +* +* @param value - fill value +* @param buffer - `ArrayBuffer` +* @param dtype - data type (default: 'float64') +* @returns filled array +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf ); +* // returns [ 1.0, 1.0, 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 'float32' ); +* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures + + +// EXPORTS // + +export = filledarray; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..97a1f39 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import a 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@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var u=r.isPrimitive,f=e.isPrimitive,g=t,j=i,y=n,v=s,b=a,c=o,w=l,x=m,E=p,k=h,M=d();function T(r,e){var t;for(t=[];!r.next().done;)t.push(e);return t}function V(r,e){var t;for(t=0;t=0&&u(arguments[e])?(t=arguments[e],e-=1):t="float64",null===(i=b(t)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",t));if("generic"===t){if(e<=0)return[];if(r=arguments[0],a=arguments[1],1===e){if(f(a)?s=a:g(a)&&(s=a.length),void 0!==s)return w(r,s);if(j(a))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(y(a)){if(!1===M)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",a));if(!v(a[x]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(a=a[x](),!v(a.next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));return T(a,r)}throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a))}if(j(a))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`.",a))}if(e<=0)return new i(0);if(1===e)if(g(a=arguments[1]))n=new i(a.length);else if(j(a))n=new i(a);else if(f(a))n=new i(a);else{if(!y(a))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(!1===M)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",a));if(!v(a[x]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(a=a[x](),!v(a.next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));n=new i(E(a))}else n=2===e?new i(arguments[1],arguments[2]):new i(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(t)?V(n,arguments[0]):c(n.length,arguments[0],n,1)),n};export{A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d44c59d --- /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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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","gfill","require$$7","filled","require$$8","ITERATOR_SYMBOL","require$$10","iterLength","require$$11","format","require$$12","HAS_ITERATOR_SYMBOL","require$$9","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","lib","nargs","dtype","ctor","len","arg","arguments","TypeError","Error","test"],"mappings":";;omCAsBA,IAAIA,EAAWC,EAAsCC,YACjDC,EAAuBC,EAAmDF,YAC1EG,EAAeC,EACfC,EAAgBC,EAChBC,EAAWC,EACXC,EAAaC,EACbC,EAAQC,EACRC,EAAQC,EACRC,EAASC,EAETC,EAAkBC,EAClBC,EAAaC,EACbC,EAASC,EAKTC,EAR2BC,IAqB/B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EAqMR,IClJAQ,ED4CA,WACC,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKvC,EAAU4C,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAO5B,EAAO2B,IAEb,MAAM,IAAIK,UAAWtB,EAAQ,sEAAuEiB,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKpC,EAAsBwC,GAC1BD,EAAMC,EACKtC,EAAcsC,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOzB,EAAQY,EAAOa,GAEvB,GAAKnC,EAAeoC,GACnB,MAAM,IAAIG,MAAO,qFAElB,GAAKrC,EAAUkC,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIoB,UAAWtB,EAAQ,sIAAuIoB,IAErK,IAAMhC,EAAYgC,EAAKxB,IACtB,MAAM,IAAI0B,UAAWtB,EAAQ,wGAAyGoB,IAGvI,GADAA,EAAMA,EAAKxB,MACLR,EAAYgC,EAAIZ,MACrB,MAAM,IAAIc,UAAWtB,EAAQ,wGAAyGoB,IAEvI,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIgB,UAAWtB,EAAQ,wGAAyGoB,IAChI,GAAKpC,EAAeoC,GAC1B,MAAM,IAAIG,MAAO,qFAElB,MAAM,IAAID,UAAWtB,EAAQ,wGAAyGoB,IAEvI,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKlC,EADLsC,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAK7B,EAAeoC,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKxC,EAAsBwC,GACjCb,EAAM,IAAIW,EAAME,OACV,CAAA,IAAKlC,EAAUkC,GAarB,MAAM,IAAIE,UAAWtB,EAAQ,wGAAyGoB,IAZtI,IAA6B,IAAxBlB,EACJ,MAAM,IAAIoB,UAAWtB,EAAQ,sIAAuIoB,IAErK,IAAMhC,EAAYgC,EAAKxB,IACtB,MAAM,IAAI0B,UAAWtB,EAAQ,wGAAyGoB,IAGvI,GADAA,EAAMA,EAAKxB,MACLR,EAAYgC,EAAIZ,MACrB,MAAM,IAAIc,UAAWtB,EAAQ,wGAAyGoB,IAEvIb,EAAM,IAAIW,EAAMpB,EAAYsB,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWW,KAAMP,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjC7B,EAAOe,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..f8cd9c3 --- /dev/null +++ b/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/array-filled", + "version": "0.0.0", + "description": "Create a filled array.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/array-filled.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", + "clamped", + "short", + "long", + "generic", + "fill", + "filled" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5a77f5f --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 9c8149b0820a1118084046a4a72aacf4d9053a11 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 01:33:03 +0000 Subject: [PATCH 002/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 864dacc..2720b98 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 22fc347109cba1c606add74f34afd48ff326dec6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:21:13 +0000 Subject: [PATCH 003/108] Remove files --- index.d.ts | 217 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2911 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 97a1f39..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import a 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@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var u=r.isPrimitive,f=e.isPrimitive,g=t,j=i,y=n,v=s,b=a,c=o,w=l,x=m,E=p,k=h,M=d();function T(r,e){var t;for(t=[];!r.next().done;)t.push(e);return t}function V(r,e){var t;for(t=0;t=0&&u(arguments[e])?(t=arguments[e],e-=1):t="float64",null===(i=b(t)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",t));if("generic"===t){if(e<=0)return[];if(r=arguments[0],a=arguments[1],1===e){if(f(a)?s=a:g(a)&&(s=a.length),void 0!==s)return w(r,s);if(j(a))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(y(a)){if(!1===M)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",a));if(!v(a[x]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(a=a[x](),!v(a.next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));return T(a,r)}throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a))}if(j(a))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`.",a))}if(e<=0)return new i(0);if(1===e)if(g(a=arguments[1]))n=new i(a.length);else if(j(a))n=new i(a);else if(f(a))n=new i(a);else{if(!y(a))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(!1===M)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",a));if(!v(a[x]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(a=a[x](),!v(a.next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));n=new i(E(a))}else n=2===e?new i(arguments[1],arguments[2]):new i(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(t)?V(n,arguments[0]):c(n.length,arguments[0],n,1)),n};export{A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d44c59d..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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","gfill","require$$7","filled","require$$8","ITERATOR_SYMBOL","require$$10","iterLength","require$$11","format","require$$12","HAS_ITERATOR_SYMBOL","require$$9","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","lib","nargs","dtype","ctor","len","arg","arguments","TypeError","Error","test"],"mappings":";;omCAsBA,IAAIA,EAAWC,EAAsCC,YACjDC,EAAuBC,EAAmDF,YAC1EG,EAAeC,EACfC,EAAgBC,EAChBC,EAAWC,EACXC,EAAaC,EACbC,EAAQC,EACRC,EAAQC,EACRC,EAASC,EAETC,EAAkBC,EAClBC,EAAaC,EACbC,EAASC,EAKTC,EAR2BC,IAqB/B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EAqMR,IClJAQ,ED4CA,WACC,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKvC,EAAU4C,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAO5B,EAAO2B,IAEb,MAAM,IAAIK,UAAWtB,EAAQ,sEAAuEiB,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKpC,EAAsBwC,GAC1BD,EAAMC,EACKtC,EAAcsC,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOzB,EAAQY,EAAOa,GAEvB,GAAKnC,EAAeoC,GACnB,MAAM,IAAIG,MAAO,qFAElB,GAAKrC,EAAUkC,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIoB,UAAWtB,EAAQ,sIAAuIoB,IAErK,IAAMhC,EAAYgC,EAAKxB,IACtB,MAAM,IAAI0B,UAAWtB,EAAQ,wGAAyGoB,IAGvI,GADAA,EAAMA,EAAKxB,MACLR,EAAYgC,EAAIZ,MACrB,MAAM,IAAIc,UAAWtB,EAAQ,wGAAyGoB,IAEvI,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIgB,UAAWtB,EAAQ,wGAAyGoB,IAChI,GAAKpC,EAAeoC,GAC1B,MAAM,IAAIG,MAAO,qFAElB,MAAM,IAAID,UAAWtB,EAAQ,wGAAyGoB,IAEvI,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKlC,EADLsC,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAK7B,EAAeoC,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKxC,EAAsBwC,GACjCb,EAAM,IAAIW,EAAME,OACV,CAAA,IAAKlC,EAAUkC,GAarB,MAAM,IAAIE,UAAWtB,EAAQ,wGAAyGoB,IAZtI,IAA6B,IAAxBlB,EACJ,MAAM,IAAIoB,UAAWtB,EAAQ,sIAAuIoB,IAErK,IAAMhC,EAAYgC,EAAKxB,IACtB,MAAM,IAAI0B,UAAWtB,EAAQ,wGAAyGoB,IAGvI,GADAA,EAAMA,EAAKxB,MACLR,EAAYgC,EAAIZ,MACrB,MAAM,IAAIc,UAAWtB,EAAQ,wGAAyGoB,IAEvIb,EAAM,IAAIW,EAAMpB,EAAYsB,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWW,KAAMP,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjC7B,EAAOe,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5a77f5f..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c12f9b306f1ca4786bc3911cfdbeadc7d3fd9e8f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:21:55 +0000 Subject: [PATCH 004/108] 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 | 43 +- benchmark/benchmark.js | 274 --- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 -- docs/types/test.ts | 201 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 --- package.json | 89 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 2473 ------------------- 49 files changed, 2715 insertions(+), 7691 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 (98%) 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 bdd5afd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T23:01:46.139Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 ca90a22..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) 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..70104d7 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(b=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new b(0);if(1===g)if(t(u=arguments[1]))v=new b(u.length);else if(s(u))v=new b(u);else if(r(u))v=new b(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));v=new b(f(u))}else v=2===g?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return v.length>0&&(/^complex/.test(c)?a(v,arguments[0]):m(v.length,arguments[0],v,1)),v}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..4cc93a9 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;2oCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2720b98..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..60195bc --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 374e694ea3c9eb1d3e751e7c9f3e9a58a5cb0f83 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 20:59:46 +0000 Subject: [PATCH 005/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 864dacc..2720b98 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 56c03186b32a34e4bcc4ac9fd61d83d7ee930df4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:30:00 +0000 Subject: [PATCH 006/108] Remove files --- index.d.ts | 217 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2911 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 70104d7..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(b=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new b(0);if(1===g)if(t(u=arguments[1]))v=new b(u.length);else if(s(u))v=new b(u);else if(r(u))v=new b(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));v=new b(f(u))}else v=2===g?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return v.length>0&&(/^complex/.test(c)?a(v,arguments[0]):m(v.length,arguments[0],v,1)),v}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 4cc93a9..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;2oCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 60195bc..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From d63c15e5b3545388bc71ecef6628b570991e3c5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:30:45 +0000 Subject: [PATCH 007/108] 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 | 43 +- benchmark/benchmark.js | 274 --- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 -- docs/types/test.ts | 201 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 --- package.json | 89 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 2473 ------------------- 49 files changed, 2715 insertions(+), 7691 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 (98%) 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 3c4a08a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:49:03.952Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 ca90a22..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) 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..70104d7 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(b=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new b(0);if(1===g)if(t(u=arguments[1]))v=new b(u.length);else if(s(u))v=new b(u);else if(r(u))v=new b(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));v=new b(f(u))}else v=2===g?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return v.length>0&&(/^complex/.test(c)?a(v,arguments[0]):m(v.length,arguments[0],v,1)),v}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..4cc93a9 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;2oCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2720b98..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..b128632 --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 e8f7f1730433f6771bdcc47b4c2e385dd9667258 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:45:46 +0000 Subject: [PATCH 008/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 864dacc..2720b98 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 80fb93a793ca6fc907f15ea7d2253fb8e9f5d94b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:10:01 +0000 Subject: [PATCH 009/108] Remove files --- index.d.ts | 217 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2911 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 70104d7..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(b=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new b(0);if(1===g)if(t(u=arguments[1]))v=new b(u.length);else if(s(u))v=new b(u);else if(r(u))v=new b(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));v=new b(f(u))}else v=2===g?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return v.length>0&&(/^complex/.test(c)?a(v,arguments[0]):m(v.length,arguments[0],v,1)),v}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 4cc93a9..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;2oCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b128632..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 8d0325aeea8535e75645eac9c076888a0fc850c2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:11:00 +0000 Subject: [PATCH 010/108] 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 | 43 +- benchmark/benchmark.js | 274 --- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 -- docs/types/test.ts | 201 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 --- package.json | 89 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 2473 ------------------- 48 files changed, 2715 insertions(+), 7656 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 (98%) 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 437e823..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) 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 ca90a22..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) 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..70104d7 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(b=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new b(0);if(1===g)if(t(u=arguments[1]))v=new b(u.length);else if(s(u))v=new b(u);else if(r(u))v=new b(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));v=new b(f(u))}else v=2===g?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return v.length>0&&(/^complex/.test(c)?a(v,arguments[0]):m(v.length,arguments[0],v,1)),v}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..4cc93a9 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;2oCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2720b98..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..17f009c --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 ec0e7c3886a91538aec754b6284b3617f7cdb39f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 04:03:23 +0000 Subject: [PATCH 011/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 864dacc..2720b98 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 2d56999ca055a815dee0b936ac170f5e751cccf9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:56:34 +0000 Subject: [PATCH 012/108] Remove files --- index.d.ts | 217 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2911 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 70104d7..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(b=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new b(0);if(1===g)if(t(u=arguments[1]))v=new b(u.length);else if(s(u))v=new b(u);else if(r(u))v=new b(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));v=new b(f(u))}else v=2===g?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return v.length>0&&(/^complex/.test(c)?a(v,arguments[0]):m(v.length,arguments[0],v,1)),v}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 4cc93a9..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;2oCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 17f009c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 94a007066053226c65b8d5bbe6fd8a90cdff29da Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:57:23 +0000 Subject: [PATCH 013/108] 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 | 43 +- benchmark/benchmark.js | 274 --- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 -- docs/types/test.ts | 201 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 --- package.json | 89 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 2473 ------------------- 49 files changed, 2715 insertions(+), 7730 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 (98%) 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 895e5a9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:50:43.240Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 ca90a22..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) 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..7091693 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8d51013 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;kpCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2720b98..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..df931fa --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 09a19dc2ac08c8687534aa97fa86edd4e029c85a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:54:28 +0000 Subject: [PATCH 014/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 864dacc..2720b98 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 55adcb0561eab6ddca1610ce2229e7bee1b6c8fa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 14:25:00 +0000 Subject: [PATCH 015/108] Remove files --- index.d.ts | 217 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2911 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7091693..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8d51013..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;kpCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index df931fa..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 047b00ba7570405ac03ab39536f8fabc4161be12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 14:26:07 +0000 Subject: [PATCH 016/108] 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 | 43 +- benchmark/benchmark.js | 274 --- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 -- docs/types/test.ts | 201 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 --- package.json | 89 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 2473 ------------------- 49 files changed, 2715 insertions(+), 7746 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 (98%) 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 1ad9f62..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:51:39.899Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 ca90a22..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) 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..58dab6d --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ba6a9f3 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2720b98..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..1544581 --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 8e3b066cc8e410a68330059080e1f57607ae7210 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:24:47 +0000 Subject: [PATCH 017/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 864dacc..2720b98 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 69ad263c7c862081488d399efefd17985ce8cea0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 2 Oct 2022 00:08:05 +0000 Subject: [PATCH 018/108] Remove files --- index.d.ts | 217 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2911 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 58dab6d..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ba6a9f3..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1544581..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 3758a34c56802944f99ae4d93a280f5daa6c11f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 2 Oct 2022 00:09:13 +0000 Subject: [PATCH 019/108] 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 | 43 +- benchmark/benchmark.js | 274 --- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 -- docs/types/test.ts | 201 -- examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 --- package.json | 89 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 2473 ------------------- 49 files changed, 2715 insertions(+), 7746 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 (98%) 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 a994ef8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:20:09.668Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 ca90a22..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) 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..58dab6d --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ba6a9f3 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2720b98..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..f8f1535 --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 4a0e451ce070d52361a046e4768c1275e344f6cf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:07:12 +0000 Subject: [PATCH 020/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 864dacc..2720b98 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 3c969060b93e506c75f2daa6e45576493e48801b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:18:55 +0000 Subject: [PATCH 021/108] Remove files --- index.d.ts | 217 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2911 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 58dab6d..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ba6a9f3..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,EAWR,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,EA+FR,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,GAE7B,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,IAChC,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,IAEvC,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,SAK7Bb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f8f1535..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0af84e307245391f3c5f27ea8a14b36c927bad6b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:19:51 +0000 Subject: [PATCH 022/108] 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 | 43 +- benchmark/benchmark.js | 274 -- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 - docs/types/test.ts | 201 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 -- package.json | 89 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 2473 ------------- 49 files changed, 4070 insertions(+), 7746 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 (98%) 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 fdd44e0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T02:04:39.821Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 ca90a22..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) 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 024114c..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: '45 21 * * 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..58dab6d --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c2c7da2 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2720b98..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..c38228d --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 76d56f9dc169b2a6d3526b2f521eae4360dee536 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 04:44:40 +0000 Subject: [PATCH 023/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 864dacc..2720b98 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 f3fade627bcab97f618808faeaafc56a81b7bd36 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 17:44:05 +0000 Subject: [PATCH 024/108] Remove files --- index.d.ts | 217 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4266 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 58dab6d..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c2c7da2..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c38228d..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f0644a5b4740e7986a8b584f553808ea1caf54b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 17:45:14 +0000 Subject: [PATCH 025/108] 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 | 43 +- benchmark/benchmark.js | 274 -- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 - docs/types/test.ts | 201 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 -- package.json | 89 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 2473 ------------- 49 files changed, 4070 insertions(+), 7767 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 (98%) 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 fd734e7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T23:11:49.515Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 ca90a22..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) 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 024114c..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: '45 21 * * 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..58dab6d --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c2c7da2 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2720b98..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..2a0d2c3 --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 4b7110bdab2f847c3d4fecdbda0ae4c09a68b669 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:48:13 +0000 Subject: [PATCH 026/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 27cf40c..2ee2de7 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 c7a2d2f0d1490dbcf66a65469f859ad8ea0b71e1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 12:56:57 +0000 Subject: [PATCH 027/108] Remove files --- index.d.ts | 217 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4266 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 58dab6d..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c2c7da2..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill' ;\nimport filled from '@stdlib/array-base-filled' ;\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer' ;\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2a0d2c3..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From d3b57ba81d830c17286985b92fd40c9ead27be0a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 12:58:06 +0000 Subject: [PATCH 028/108] 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 | 43 +- benchmark/benchmark.js | 274 -- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 - docs/types/test.ts | 201 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 -- package.json | 89 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 2473 ------------- 49 files changed, 4070 insertions(+), 7772 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 (98%) 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 8670739..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:59:22.495Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 ca90a22..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) 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 024114c..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: '45 21 * * 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..58dab6d --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a25f391 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2ee2de7..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..42454bc --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 4201c0d7a12e31060f17d2497adfcc88327a45c2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:17:11 +0000 Subject: [PATCH 029/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 03ad19e..2f77f1a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,7 +32,7 @@ var filled = require( '@stdlib/array-base-filled' ); 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 // @@ -192,7 +192,7 @@ function filledarray() { } 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( '00M2k', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -210,26 +210,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } 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( '00M2l', 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( '00M2m', 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( '00M2m', arg ) ); } return filledIterator( arg, value ); } - 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( '00M2m', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format( '00M04' ) ); } - 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( '00M2m', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -244,18 +244,18 @@ function filledarray() { 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( '00M2l', 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( '00M2m', 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( '00M2m', 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( '00M2m', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index a53d9af..dab3f6b 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.0.x", "@stdlib/blas-ext-base-gfill": "^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 2e2e3c20c386e3065c964fed2276321d5c49ad69 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 10:14:09 +0000 Subject: [PATCH 030/108] Remove files --- index.d.ts | 217 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4266 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 58dab6d..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a25f391..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 42454bc..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 8efc28484d408c2ea32fda5e0a4fad998d39a74d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 10:15:07 +0000 Subject: [PATCH 031/108] 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 | 43 +- benchmark/benchmark.js | 274 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - docs/repl.txt | 157 - docs/types/test.ts | 201 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 - package.json | 89 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 2473 --------- 49 files changed, 6203 insertions(+), 7783 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 (98%) 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 5d02724..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:35:56.327Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 ca90a22..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) 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 024114c..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: '45 21 * * 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 + + ```
@@ -253,7 +246,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]. @@ -321,7 +314,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@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/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c11e1b2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 75b8b31..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 fb0a85e..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 5626bc0..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 8f2651f..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 bc1c4ac..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArray = require( '@stdlib/assert-is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 e271641..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4106e59..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 4335be8..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d17e7ab..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 667cf11..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a06f397..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 083e121..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 428d30d..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" -click B href "https://github.com/stdlib-js/array-filled/tree/main" -click C href "https://github.com/stdlib-js/array-filled/tree/production" -click D href "https://github.com/stdlib-js/array-filled/tree/esm" -click E href "https://github.com/stdlib-js/array-filled/tree/deno" -click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index edbe51c..daebabf 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..ccaf0aa --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a25f391 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 2f77f1a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( '00M2k', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00M2m', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format( '00M04' ) ); - } - throw new TypeError( format( '00M2m', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00M2l', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00M2m', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00M2m', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index dab3f6b..3c16942 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..4e4df0d --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 4fafa7f251ab1e8321ef37ab3b03f6ab6234bf3e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:46:30 +0000 Subject: [PATCH 032/108] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c3d67e0..a4c59e1 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/blas-ext-base-gfill": "^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 2085e8619b524370e003c4a2a1493367f1de59a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:19:52 +0000 Subject: [PATCH 033/108] Remove files --- index.d.ts | 217 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6399 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 daebabf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,217 +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. -*/ - -// 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; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; // tslint:disable-line:max-line-length unified-signatures - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ccaf0aa..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as r}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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.0.10-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f 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 j=l();function w(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function a(e,r){var t;for(t=0;t=0&&e(arguments[g])?(c=arguments[g],g-=1):c="float64",null===(v=o(c)))throw new TypeError(p("00M2k",c));if("generic"===c){if(g<=0)return[];if(l=arguments[0],u=arguments[1],1===g){if(r(u)?x=u:t(u)&&(x=u.length),void 0!==x)return d(l,x);if(s(u))throw new Error(p("00M04"));if(i(u)){if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));return w(u,l)}throw new TypeError(p("00M2m",u))}if(s(u))throw new Error(p("00M04"));throw new TypeError(p("00M2m",u))}if(g<=0)return new v(0);if(1===g)if(t(u=arguments[1]))b=new v(u.length);else if(s(u))b=new v(u);else if(r(u))b=new v(u);else{if(!i(u))throw new TypeError(p("00M2m",u));if(!1===j)throw new TypeError(p("00M2l",u));if(!n(u[h]))throw new TypeError(p("00M2m",u));if(u=u[h](),!n(u.next))throw new TypeError(p("00M2m",u));b=new v(f(u))}else b=2===g?new v(arguments[1],arguments[2]):new v(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(c)?a(b,arguments[0]):m(b.length,arguments[0],b,1)),b}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a25f391..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '00M2k', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format( '00M04' ) );\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( '00M2l', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format( '00M04' ) );\n\t\t}\n\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00M2l', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00M2m', 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( '00M2m', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00M2m', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;0pCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,GAAKM,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvC,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,QAASL,GACzC,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAOL,EAAQ,UAE1B,MAAM,IAAID,UAAWC,EAAQ,QAASL,GACtC,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAZtC,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,QAASL,IAEvC,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASL,IAGvC,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,QAASL,IAEvCb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4e4df0d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ad943f81b93b892857a77354519d5dcdb281e9ad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:20:19 +0000 Subject: [PATCH 034/108] 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 | 274 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 201 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 - package.json | 89 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 --------- 55 files changed, 6204 insertions(+), 8060 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 (98%) 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 ab18034..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:41:41.573Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 51c690b..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) 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 f731d89..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: '45 21 * * 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 + + ```
@@ -265,7 +258,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]. @@ -333,9 +326,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 8417b40..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 26200c9..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 56ffb0b..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 77aa49d..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e320d2b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(A,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),q=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),T=require('@stdlib/iter-length/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=q();function k(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function M(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a="float64",t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return k(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(T(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?M(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=j -});var V=m();module.exports=V; -/** @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 9b70df5..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAA2B,QAAS,4CAA6C,EACjFC,EAAkB,QAAS,yBAA0B,EACrDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAsBJ,EAAyB,EAanD,SAASK,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKtB,EAAU,UAAWsB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQ,UAETC,EAAOlB,EAAOiB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWZ,EAAQ,sEAAuEW,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKrB,EAAsByB,CAAI,EAC9BD,EAAMC,EACKxB,EAAcwB,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOjB,EAAQQ,EAAOS,CAAI,EAE3B,GAAKtB,EAAeuB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKtB,EAAUsB,CAAI,EAAI,CACtB,GAAKb,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIc,CAAI,CAAE,EAE3K,GAAK,CAACrB,EAAYqB,EAAKhB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWE,EAAQ,wGAAyGc,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKhB,CAAgB,EAAE,EACxB,CAACL,EAAYqB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWd,EAAQ,wGAAyGc,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWJ,EAAQ,wGAAyGc,CAAI,CAAE,CAC7I,SAAYvB,EAAeuB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWd,EAAQ,wGAAyGc,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACdxB,EAAcwB,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChBvB,EAAeuB,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAsByB,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTtB,EAAUsB,CAAI,EAAI,CAC7B,GAAKb,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIc,CAAI,CAAE,EAE3K,GAAK,CAACrB,EAAYqB,EAAKhB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWE,EAAQ,wGAAyGc,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKhB,CAAgB,EAAE,EACxB,CAACL,EAAYqB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWd,EAAQ,wGAAyGc,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMb,EAAYe,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWd,EAAQ,wGAAyGc,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCV,EAAOU,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKAlB,EAAO,QAAUsB,ICvJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "format", "HAS_ITERATOR_SYMBOL", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index b279c73..00a8ca5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { RealOrComplexTypedArray, DataType, Collection } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..54a2332 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import a 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@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var h=d();function u(r,e){var t;for(t=[];!r.next().done;)t.push(e);return t}function f(r,e){var t;for(t=0;t=0&&r(arguments[g])?(j=arguments[g],g-=1):j="float64",null===(y=a(j)))throw new TypeError(v("invalid argument. Must provide a recognized data type. Value: `%s`.",j));if("generic"===j){if(g<=0)return[];if(d=arguments[0],w=arguments[1],1===g){if(e(w)?c=w:t(w)&&(c=w.length),void 0!==c)return l(d,c);if(i(w))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(n(w)){if(!1===h)throw new TypeError(v("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",w));if(!s(w[m]))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(w=w[m](),!s(w.next))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));return u(w,d)}throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w))}if(i(w))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w))}if(g<=0)return new y(0);if(1===g)if(t(w=arguments[1]))b=new y(w.length);else if(i(w))b=new y(w);else if(e(w))b=new y(w);else{if(!n(w))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(!1===h)throw new TypeError(v("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",w));if(!s(w[m]))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(w=w[m](),!s(w.next))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));b=new y(p(w))}else b=2===g?new y(arguments[1],arguments[2]):new y(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(j)?f(b,arguments[0]):o(b.length,arguments[0],b,1)),b}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a2aeaf5 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;6tCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAO,qFAElB,GAAKC,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAO,qFAElB,MAAM,IAAIN,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvIb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 03ad19e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - 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 filledIterator( arg, value ); - } - 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 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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 === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index a4c59e1..d112e44 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..7e1b49e --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 ebdfa5421348636a951497b7cfa4f6e65def4f3f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:17:55 +0000 Subject: [PATCH 035/108] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c3d67e0..a4c59e1 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/blas-ext-base-gfill": "^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 2ca8fee30d75296d5a672cf50a874cc428bc5726 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:43:43 +0000 Subject: [PATCH 036/108] Remove files --- index.d.ts | 216 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6398 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 00a8ca5..0000000 --- a/index.d.ts +++ /dev/null @@ -1,216 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { RealOrComplexTypedArray, DataType, Collection } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( `@stdlib/iter/constant` ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( `@stdlib/array/buffer` ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 54a2332..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import a 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@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var h=d();function u(r,e){var t;for(t=[];!r.next().done;)t.push(e);return t}function f(r,e){var t;for(t=0;t=0&&r(arguments[g])?(j=arguments[g],g-=1):j="float64",null===(y=a(j)))throw new TypeError(v("invalid argument. Must provide a recognized data type. Value: `%s`.",j));if("generic"===j){if(g<=0)return[];if(d=arguments[0],w=arguments[1],1===g){if(e(w)?c=w:t(w)&&(c=w.length),void 0!==c)return l(d,c);if(i(w))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(n(w)){if(!1===h)throw new TypeError(v("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",w));if(!s(w[m]))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(w=w[m](),!s(w.next))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));return u(w,d)}throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w))}if(i(w))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w))}if(g<=0)return new y(0);if(1===g)if(t(w=arguments[1]))b=new y(w.length);else if(i(w))b=new y(w);else if(e(w))b=new y(w);else{if(!n(w))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(!1===h)throw new TypeError(v("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",w));if(!s(w[m]))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(w=w[m](),!s(w.next))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));b=new y(p(w))}else b=2===g?new y(arguments[1],arguments[2]):new y(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(j)?f(b,arguments[0]):o(b.length,arguments[0],b,1)),b}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a2aeaf5..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;6tCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAO,qFAElB,GAAKC,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAO,qFAElB,MAAM,IAAIN,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvIb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7e1b49e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5c3f1582dbe5b85de8363993e598f6ba0ebeb114 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:44:12 +0000 Subject: [PATCH 037/108] 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 | 274 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 201 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 278 - package.json | 89 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 --------- 54 files changed, 6204 insertions(+), 8059 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 (98%) 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 437e823..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) 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 51c690b..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) 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 f731d89..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: '45 21 * * 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 + + ```
@@ -265,7 +258,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]. @@ -333,9 +326,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 8417b40..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 26200c9..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 56ffb0b..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 77aa49d..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e320d2b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(A,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),q=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),T=require('@stdlib/iter-length/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=q();function k(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function M(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a="float64",t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return k(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(T(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?M(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=j -});var V=m();module.exports=V; -/** @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 9b70df5..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAA2B,QAAS,4CAA6C,EACjFC,EAAkB,QAAS,yBAA0B,EACrDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAsBJ,EAAyB,EAanD,SAASK,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKtB,EAAU,UAAWsB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQ,UAETC,EAAOlB,EAAOiB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWZ,EAAQ,sEAAuEW,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKrB,EAAsByB,CAAI,EAC9BD,EAAMC,EACKxB,EAAcwB,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOjB,EAAQQ,EAAOS,CAAI,EAE3B,GAAKtB,EAAeuB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKtB,EAAUsB,CAAI,EAAI,CACtB,GAAKb,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIc,CAAI,CAAE,EAE3K,GAAK,CAACrB,EAAYqB,EAAKhB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWE,EAAQ,wGAAyGc,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKhB,CAAgB,EAAE,EACxB,CAACL,EAAYqB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWd,EAAQ,wGAAyGc,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWJ,EAAQ,wGAAyGc,CAAI,CAAE,CAC7I,SAAYvB,EAAeuB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWd,EAAQ,wGAAyGc,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,IAAU,EAEd,GADAI,EAAM,UAAW,CAAE,EACdxB,EAAcwB,CAAI,EACtBT,EAAM,IAAIO,EAAME,EAAI,MAAO,UAChBvB,EAAeuB,CAAI,EAC9BT,EAAM,IAAIO,EAAME,CAAI,UACTzB,EAAsByB,CAAI,EACrCT,EAAM,IAAIO,EAAME,CAAI,UACTtB,EAAUsB,CAAI,EAAI,CAC7B,GAAKb,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIc,CAAI,CAAE,EAE3K,GAAK,CAACrB,EAAYqB,EAAKhB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWE,EAAQ,wGAAyGc,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKhB,CAAgB,EAAE,EACxB,CAACL,EAAYqB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWd,EAAQ,wGAAyGc,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMb,EAAYe,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWd,EAAQ,wGAAyGc,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCV,EAAOU,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKAlB,EAAO,QAAUsB,ICvJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "format", "HAS_ITERATOR_SYMBOL", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index da969b6..9459c4b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { RealOrComplexTypedArray, DataType, Collection } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..54a2332 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import a 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@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var h=d();function u(r,e){var t;for(t=[];!r.next().done;)t.push(e);return t}function f(r,e){var t;for(t=0;t=0&&r(arguments[g])?(j=arguments[g],g-=1):j="float64",null===(y=a(j)))throw new TypeError(v("invalid argument. Must provide a recognized data type. Value: `%s`.",j));if("generic"===j){if(g<=0)return[];if(d=arguments[0],w=arguments[1],1===g){if(e(w)?c=w:t(w)&&(c=w.length),void 0!==c)return l(d,c);if(i(w))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(n(w)){if(!1===h)throw new TypeError(v("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",w));if(!s(w[m]))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(w=w[m](),!s(w.next))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));return u(w,d)}throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w))}if(i(w))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w))}if(g<=0)return new y(0);if(1===g)if(t(w=arguments[1]))b=new y(w.length);else if(i(w))b=new y(w);else if(e(w))b=new y(w);else{if(!n(w))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(!1===h)throw new TypeError(v("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",w));if(!s(w[m]))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(w=w[m](),!s(w.next))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));b=new y(p(w))}else b=2===g?new y(arguments[1],arguments[2]):new y(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(j)?f(b,arguments[0]):o(b.length,arguments[0],b,1)),b}export{g as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a2aeaf5 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;6tCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAO,qFAElB,GAAKC,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAO,qFAElB,MAAM,IAAIN,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvIb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 03ad19e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,278 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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(); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = 'float64'; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - 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 filledIterator( arg, value ); - } - 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 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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 === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index a4c59e1..d112e44 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-filled": "^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": "^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", - "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..2c95c07 --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 ab7ecefae70de61de051ba5106ec77c606eb417f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jan 2024 08:38:28 +0000 Subject: [PATCH 038/108] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e220eb1..ee536fa 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/blas-ext-base-gfill": "^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 5a519a8934240b5f30a828c68929d67b86e38b2b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jan 2024 08:39:55 +0000 Subject: [PATCH 039/108] Remove files --- index.d.ts | 216 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6398 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 9459c4b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,216 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { RealOrComplexTypedArray, DataType, Collection } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 54a2332..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import a 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@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var h=d();function u(r,e){var t;for(t=[];!r.next().done;)t.push(e);return t}function f(r,e){var t;for(t=0;t=0&&r(arguments[g])?(j=arguments[g],g-=1):j="float64",null===(y=a(j)))throw new TypeError(v("invalid argument. Must provide a recognized data type. Value: `%s`.",j));if("generic"===j){if(g<=0)return[];if(d=arguments[0],w=arguments[1],1===g){if(e(w)?c=w:t(w)&&(c=w.length),void 0!==c)return l(d,c);if(i(w))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(n(w)){if(!1===h)throw new TypeError(v("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",w));if(!s(w[m]))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(w=w[m](),!s(w.next))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));return u(w,d)}throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w))}if(i(w))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w))}if(g<=0)return new y(0);if(1===g)if(t(w=arguments[1]))b=new y(w.length);else if(i(w))b=new y(w);else if(e(w))b=new y(w);else{if(!n(w))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(!1===h)throw new TypeError(v("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",w));if(!s(w[m]))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));if(w=w[m](),!s(w.next))throw new TypeError(v("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",w));b=new y(p(w))}else b=2===g?new y(arguments[1],arguments[2]):new y(arguments[1],arguments[2],arguments[3]);return b.length>0&&(/^complex/.test(j)?f(b,arguments[0]):o(b.length,arguments[0],b,1)),b}export{g as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a2aeaf5..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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();\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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 = 'float64';\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;6tCAuCA,IAAIA,EAAsBC,IAa1B,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQ,UAGK,QADdC,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAO,qFAElB,GAAKC,EAAUX,GAAQ,CACtB,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAO,qFAElB,MAAM,IAAIN,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBlB,EACJ,MAAM,IAAIsB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvIb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2c95c07..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 056be760e75d198bdd889d9c4c3b347de508d187 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 16 Jan 2024 08:40:25 +0000 Subject: [PATCH 040/108] 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 | 274 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 201 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 280 - package.json | 90 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 --------- 54 files changed, 6204 insertions(+), 8062 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 (98%) 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 437e823..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) 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 51c690b..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) 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 f731d89..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: '45 21 * * 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 + + ```
@@ -265,7 +258,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]. @@ -333,9 +326,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 8417b40..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 26200c9..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 56ffb0b..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 77aa49d..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[esm-url]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c17c35b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(B,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),T=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),q=require('@stdlib/iter-length/dist'),k=require('@stdlib/array-defaults/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=T(),M=k.get("dtypes.default");function j(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function V(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a=M,t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return j(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(q(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?V(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=A -});var S=m();module.exports=S; -/** @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 08a4b31..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAQU,EAAOS,CAAI,EAE3B,GAAKxB,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCZ,EAAOY,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKApB,EAAO,QAAUwB,ICzJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index da969b6..9459c4b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { RealOrComplexTypedArray, DataType, Collection } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..196366a --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as r}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 s 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 a 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@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var u=d(),f=v.get("dtypes.default");function g(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function j(e,r){var t;for(t=0;t=0&&e(arguments[v])?(y=arguments[v],v-=1):y=f,null===(b=a(y)))throw new TypeError(h("invalid argument. Must provide a recognized data type. Value: `%s`.",y));if("generic"===y){if(v<=0)return[];if(d=arguments[0],x=arguments[1],1===v){if(r(x)?w=x:t(x)&&(w=x.length),void 0!==w)return l(d,w);if(i(x))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(s(x)){if(!1===u)throw new TypeError(h("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",x));if(!n(x[m]))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(x=x[m](),!n(x.next))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));return g(x,d)}throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x))}if(i(x))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x))}if(v<=0)return new b(0);if(1===v)if(t(x=arguments[1]))c=new b(x.length);else if(i(x))c=new b(x);else if(r(x))c=new b(x);else{if(!s(x))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(!1===u)throw new TypeError(h("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",x));if(!n(x[m]))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(x=x[m](),!n(x.next))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));c=new b(p(x))}else c=2===v?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(y)?j(c,arguments[0]):o(c.length,arguments[0],c,1)),c}export{y as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..256d9b8 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;szCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAalC,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQhB,EAGK,QADdiB,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAO,qFAElB,GAAKC,EAAUX,GAAQ,CACtB,IAA6B,IAAxBrB,EACJ,MAAM,IAAIyB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAO,qFAElB,MAAM,IAAIN,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBrB,EACJ,MAAM,IAAIyB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvIb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 1a36607..0000000 --- a/lib/main.js +++ /dev/null @@ -1,280 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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 ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - 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 filledIterator( arg, value ); - } - 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 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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 === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index ee536fa..d112e44 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^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", - "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..5a8a1d3 --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 5afca731a7248a330fea81f4d6a3c00e838c4e9d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 01:28:34 +0000 Subject: [PATCH 041/108] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5920e4f..0faa715 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.0", "@stdlib/blas-ext-base-gfill": "^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 9d8f0a68cc87cdab9f806fd27b2352872dbf655d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:54:14 +0000 Subject: [PATCH 042/108] Remove files --- index.d.ts | 216 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6398 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 9459c4b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,216 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { RealOrComplexTypedArray, DataType, Collection } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 196366a..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import{isPrimitive as r}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 s 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 a 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@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.1.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.1.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var u=d(),f=v.get("dtypes.default");function g(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function j(e,r){var t;for(t=0;t=0&&e(arguments[v])?(y=arguments[v],v-=1):y=f,null===(b=a(y)))throw new TypeError(h("invalid argument. Must provide a recognized data type. Value: `%s`.",y));if("generic"===y){if(v<=0)return[];if(d=arguments[0],x=arguments[1],1===v){if(r(x)?w=x:t(x)&&(w=x.length),void 0!==w)return l(d,w);if(i(x))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(s(x)){if(!1===u)throw new TypeError(h("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",x));if(!n(x[m]))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(x=x[m](),!n(x.next))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));return g(x,d)}throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x))}if(i(x))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x))}if(v<=0)return new b(0);if(1===v)if(t(x=arguments[1]))c=new b(x.length);else if(i(x))c=new b(x);else if(r(x))c=new b(x);else{if(!s(x))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(!1===u)throw new TypeError(h("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",x));if(!n(x[m]))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(x=x[m](),!n(x.next))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));c=new b(p(x))}else c=2===v?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(y)?j(c,arguments[0]):o(c.length,arguments[0],c,1)),c}export{y as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 256d9b8..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;szCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAalC,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQhB,EAGK,QADdiB,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAO,qFAElB,GAAKC,EAAUX,GAAQ,CACtB,IAA6B,IAAxBrB,EACJ,MAAM,IAAIyB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAO,qFAElB,MAAM,IAAIN,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBrB,EACJ,MAAM,IAAIyB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvIb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5a8a1d3..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 06a260ad7f030bb6662f19a99a7c79aedeafd26c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:55:19 +0000 Subject: [PATCH 043/108] 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 | 274 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 201 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 280 - package.json | 90 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 --------- 54 files changed, 6204 insertions(+), 8071 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 (98%) 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 437e823..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) 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 51c690b..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) 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 77b42b2..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: '45 21 * * 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 + + ```
@@ -267,7 +258,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]. @@ -338,9 +329,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 8417b40..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 26200c9..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 56ffb0b..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c17c35b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(B,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),T=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),q=require('@stdlib/iter-length/dist'),k=require('@stdlib/array-defaults/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=T(),M=k.get("dtypes.default");function j(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function V(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a=M,t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return j(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(q(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?V(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=A -});var S=m();module.exports=S; -/** @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 08a4b31..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAQU,EAAOS,CAAI,EAE3B,GAAKxB,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCZ,EAAOY,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKApB,EAAO,QAAUwB,ICzJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 164a397..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,201 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = 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 - }; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType ArrayOrTypedArray - filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray - filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 'uint32' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType RealOrComplexTypedArray - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType RealOrComplexTypedArray - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType RealOrComplexTypedArray -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index da969b6..9459c4b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { RealOrComplexTypedArray, DataType, Collection } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cba8ca2 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.0-esm/index.mjs";import{isPrimitive as r}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 s 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 a 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@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var u=d(),f=v.get("dtypes.default");function g(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function j(e,r){var t;for(t=0;t=0&&e(arguments[v])?(y=arguments[v],v-=1):y=f,null===(b=a(y)))throw new TypeError(h("invalid argument. Must provide a recognized data type. Value: `%s`.",y));if("generic"===y){if(v<=0)return[];if(d=arguments[0],x=arguments[1],1===v){if(r(x)?w=x:t(x)&&(w=x.length),void 0!==w)return l(d,w);if(i(x))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(s(x)){if(!1===u)throw new TypeError(h("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",x));if(!n(x[m]))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(x=x[m](),!n(x.next))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));return g(x,d)}throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x))}if(i(x))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x))}if(v<=0)return new b(0);if(1===v)if(t(x=arguments[1]))c=new b(x.length);else if(i(x))c=new b(x);else if(r(x))c=new b(x);else{if(!s(x))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(!1===u)throw new TypeError(h("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",x));if(!n(x[m]))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(x=x[m](),!n(x.next))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));c=new b(p(x))}else c=2===v?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(y)?j(c,arguments[0]):o(c.length,arguments[0],c,1)),c}export{y as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..256d9b8 --- /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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;szCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAalC,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQhB,EAGK,QADdiB,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAO,qFAElB,GAAKC,EAAUX,GAAQ,CACtB,IAA6B,IAAxBrB,EACJ,MAAM,IAAIyB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAO,qFAElB,MAAM,IAAIN,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBrB,EACJ,MAAM,IAAIyB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvIb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 1a36607..0000000 --- a/lib/main.js +++ /dev/null @@ -1,280 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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 ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - 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 filledIterator( arg, value ); - } - 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 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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 === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 0faa715..44a3631 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^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", - "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..56e1fed --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 7db48e8e3995db4a560a35c529a19ac7156bb831 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:38:23 +0000 Subject: [PATCH 044/108] 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 d7dd1c5..c478614 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.2.0-esm/index.mjs'; ``` #### filledarray( \[dtype] ) @@ -201,7 +201,7 @@ arr = filledarray( 1, buf, 10, 4, 'int16' ); import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.2.0-esm/index.mjs'; // Generate a random number: var r = discreteUniform( 0, 100 ); From 418427713fc87252b11b52c29dfc2050ea3b7736 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:38:23 +0000 Subject: [PATCH 045/108] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c478614..63a8df4 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@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/tags). For example, + ```javascript import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.2.0-esm/index.mjs'; ``` @@ -201,7 +206,7 @@ arr = filledarray( 1, buf, 10, 4, 'int16' ); import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.2.0-esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; // Generate a random number: var r = discreteUniform( 0, 100 ); From a2bc61c4d7ddc2543f619a945c84cf14b2260d13 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 22:03:40 +0000 Subject: [PATCH 046/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 1a36607..dc56e8c 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 // @@ -194,7 +194,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -212,26 +212,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -246,18 +246,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 7c67a0e..ba0c6ac 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill": "^0.2.0", "@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" }, From cf8c74949509e58f5847798293941466588572a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 22:44:55 +0000 Subject: [PATCH 047/108] Remove files --- index.d.ts | 216 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6398 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 9459c4b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,216 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { RealOrComplexTypedArray, DataType, Collection } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray( dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, length: number, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, array: Collection, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, iterable: IterableIterator, dtype?: DataType ): ArrayOrTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: DataType ): RealOrComplexTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: DataType ): RealOrComplexTypedArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: DataType ): RealOrComplexTypedArray; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cba8ca2..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.0-esm/index.mjs";import{isPrimitive as r}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 s 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 a 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@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@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 m from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";var u=d(),f=v.get("dtypes.default");function g(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}function j(e,r){var t;for(t=0;t=0&&e(arguments[v])?(y=arguments[v],v-=1):y=f,null===(b=a(y)))throw new TypeError(h("invalid argument. Must provide a recognized data type. Value: `%s`.",y));if("generic"===y){if(v<=0)return[];if(d=arguments[0],x=arguments[1],1===v){if(r(x)?w=x:t(x)&&(w=x.length),void 0!==w)return l(d,w);if(i(x))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(s(x)){if(!1===u)throw new TypeError(h("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",x));if(!n(x[m]))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(x=x[m](),!n(x.next))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));return g(x,d)}throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x))}if(i(x))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x))}if(v<=0)return new b(0);if(1===v)if(t(x=arguments[1]))c=new b(x.length);else if(i(x))c=new b(x);else if(r(x))c=new b(x);else{if(!s(x))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(!1===u)throw new TypeError(h("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",x));if(!n(x[m]))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));if(x=x[m](),!n(x.next))throw new TypeError(h("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",x));c=new b(p(x))}else c=2===v?new b(arguments[1],arguments[2]):new b(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(y)?j(c,arguments[0]):o(c.length,arguments[0],c,1)),c}export{y as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 256d9b8..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) 2020 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 gfill from '@stdlib/blas-ext-base-gfill';\nimport filled from '@stdlib/array-base-filled';\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledIterator","it","value","arr","next","done","push","filledAccessors","i","length","set","filledarray","nargs","dtype","ctor","len","arg","arguments","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","iterLength","test","gfill"],"mappings":";;szCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAalC,SAASC,EAAgBC,EAAIC,GAC5B,IAAIC,EAIJ,IADAA,EAAM,IAEDF,EAAGG,OACAC,MAGPF,EAAIG,KAAMJ,GAEX,OAAOC,CACR,CAUA,SAASI,EAAiBJ,EAAKD,GAC9B,IAAIM,EACJ,IAAMA,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC5BL,EAAIO,IAAKR,EAAOM,GAEjB,OAAOL,CACR,CA8FA,SAASQ,IACR,IAAIT,EACAU,EACAC,EACAC,EACAX,EACAY,EACAC,EAWJ,GATAJ,EAAQK,UAAUR,QAClBG,GAAS,IACK,GAAKM,EAAUD,UAAWL,KACvCC,EAAQI,UAAWL,GACnBA,GAAS,GAETC,EAAQhB,EAGK,QADdiB,EAAOK,EAAON,IAEb,MAAM,IAAIO,UAAWC,EAAQ,sEAAuER,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAV,EAAQe,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVL,EAAc,CAMlB,GALKU,EAAsBN,GAC1BD,EAAMC,EACKO,EAAcP,KACzBD,EAAMC,EAAIP,aAEE,IAARM,EACJ,OAAOS,EAAQtB,EAAOa,GAEvB,GAAKU,EAAeT,GACnB,MAAM,IAAIU,MAAO,qFAElB,GAAKC,EAAUX,GAAQ,CACtB,IAA6B,IAAxBrB,EACJ,MAAM,IAAIyB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvI,OAAOhB,EAAgBgB,EAAKd,EAC5B,CACD,MAAM,IAAIkB,UAAWC,EAAQ,wGAAyGL,GACzI,CAAS,GAAKS,EAAeT,GAC1B,MAAM,IAAIU,MAAO,qFAElB,MAAM,IAAIN,UAAWC,EAAQ,wGAAyGL,GACtI,CACD,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKW,EADLP,EAAMC,UAAW,IAEhBd,EAAM,IAAIW,EAAME,EAAIP,aACd,GAAKgB,EAAeT,GAC1Bb,EAAM,IAAIW,EAAME,QACV,GAAKM,EAAsBN,GACjCb,EAAM,IAAIW,EAAME,OACV,KAAKW,EAAUX,GAarB,MAAM,IAAII,UAAWC,EAAQ,wGAAyGL,IAZtI,IAA6B,IAAxBrB,EACJ,MAAM,IAAIyB,UAAWC,EAAQ,sIAAuIL,IAErK,IAAMY,EAAYZ,EAAKa,IACtB,MAAM,IAAIT,UAAWC,EAAQ,wGAAyGL,IAGvI,GADAA,EAAMA,EAAKa,MACLD,EAAYZ,EAAIZ,MACrB,MAAM,IAAIgB,UAAWC,EAAQ,wGAAyGL,IAEvIb,EAAM,IAAIW,EAAMgB,EAAYd,GAG5B,MAEDb,EADqB,IAAVS,EACL,IAAIE,EAAMG,UAAU,GAAIA,UAAU,IAElC,IAAIH,EAAMG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKd,EAAIM,OAAS,IACZ,WAAWsB,KAAMlB,GACrBN,EAAiBJ,EAAKc,UAAW,IAEjCe,EAAO7B,EAAIM,OAAQQ,UAAW,GAAKd,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 56e1fed..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4722642cea432339eb2ceae4f7fc15b82f6b6a94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 22:46:38 +0000 Subject: [PATCH 048/108] 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 | 274 -- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 280 -- package.json | 90 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 ----------- 54 files changed, 4869 insertions(+), 8064 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 (98%) 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 437e823..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -267,7 +258,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]. @@ -338,9 +329,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 8417b40..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 26200c9..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 56ffb0b..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c17c35b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(B,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),T=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),q=require('@stdlib/iter-length/dist'),k=require('@stdlib/array-defaults/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=T(),M=k.get("dtypes.default");function j(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function V(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a=M,t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return j(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(q(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?V(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=A -});var S=m();module.exports=S; -/** @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 08a4b31..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAQU,EAAOS,CAAI,EAE3B,GAAKxB,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCZ,EAAOY,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKApB,EAAO,QAAUwB,ICzJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index a0c982c..dcff58c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..60ffefa --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 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.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 dc56e8c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,280 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index ba0c6ac..44a3631 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^0.2.0", - "@stdlib/array-ctors": "^0.2.0", - "@stdlib/array-defaults": "^0.2.0", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.0", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.0", - "@stdlib/assert-is-object": "^0.2.1", - "@stdlib/assert-is-string": "^0.2.1", - "@stdlib/blas-ext-base-gfill": "^0.2.0", - "@stdlib/iter-length": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "@stdlib/types": "^0.3.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.0", - "@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.0", - "@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.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.2.0", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^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..98f95c8 --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 585fbc2d604cb6af39739f4b1ce48c87a11bae94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:08:35 +0000 Subject: [PATCH 049/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 1a36607..dc56e8c 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 // @@ -194,7 +194,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -212,26 +212,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -246,18 +246,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 993d039..0410be9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill": "^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 d24a0094198b15a889851fac24a7d287cf5854fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:33:56 +0000 Subject: [PATCH 050/108] Remove files --- index.d.ts | 213 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5060 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 dcff58c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,213 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 60ffefa..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 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.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 98f95c8..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9344988c355000dd79888c4c315d338837dd9e87 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:34:22 +0000 Subject: [PATCH 051/108] 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 | 274 -- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 280 -- package.json | 91 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 ----------- 54 files changed, 4869 insertions(+), 8065 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 (98%) 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 437e823..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -267,7 +258,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]. @@ -338,9 +329,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 8417b40..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 26200c9..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 56ffb0b..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c17c35b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(B,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),T=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),q=require('@stdlib/iter-length/dist'),k=require('@stdlib/array-defaults/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=T(),M=k.get("dtypes.default");function j(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function V(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a=M,t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return j(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(q(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?V(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=A -});var S=m();module.exports=S; -/** @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 08a4b31..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAQU,EAAOS,CAAI,EAE3B,GAAKxB,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCZ,EAAOY,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKApB,EAAO,QAAUwB,ICzJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index a0c982c..dcff58c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..811a9a1 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 dc56e8c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,280 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 0410be9..84bdfcf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^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", - "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..c0ec900 --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 6f268831683b6329c6764935a6b6c699a3e7d3f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:13:23 +0000 Subject: [PATCH 052/108] 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 68d0980..be6dd70 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.2.1-esm/index.mjs'; ``` #### filledarray( \[dtype] ) @@ -201,7 +201,7 @@ arr = filledarray( 1, buf, 10, 4, 'int16' ); import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.2.1-esm/index.mjs'; // Generate a random number: var r = discreteUniform( 0, 100 ); From 1b52702f4039ba8617c3e707dbd59a43adeff4ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:13:24 +0000 Subject: [PATCH 053/108] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index be6dd70..75529de 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@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/tags). For example, + ```javascript import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.2.1-esm/index.mjs'; ``` @@ -201,7 +206,7 @@ arr = filledarray( 1, buf, 10, 4, 'int16' ); import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.2.1-esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; // Generate a random number: var r = discreteUniform( 0, 100 ); From 7f2b2293523cec28923a767dffc65ccecb4ffcb3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:31:22 +0000 Subject: [PATCH 054/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 1a36607..dc56e8c 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 // @@ -194,7 +194,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -212,26 +212,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -246,18 +246,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index c929e88..112ab4e 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill": "^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 2e61f45d80ae6020a90324dd35e1fe6a64346fdf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:15:12 +0000 Subject: [PATCH 055/108] Remove files --- index.d.ts | 213 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5060 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 dcff58c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,213 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 811a9a1..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c0ec900..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f19cf61972052ee79e1e84e592f92fd7013bca48 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:15:31 +0000 Subject: [PATCH 056/108] 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 | 274 -- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 280 -- package.json | 91 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 ----------- 55 files changed, 4869 insertions(+), 8067 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 (98%) 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 0c8a3fa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T06:08:58.355Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -267,7 +258,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]. @@ -338,9 +329,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 8417b40..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 26200c9..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 56ffb0b..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c17c35b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(B,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),T=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),q=require('@stdlib/iter-length/dist'),k=require('@stdlib/array-defaults/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=T(),M=k.get("dtypes.default");function j(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function V(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a=M,t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return j(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(q(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?V(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=A -});var S=m();module.exports=S; -/** @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 08a4b31..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAQU,EAAOS,CAAI,EAE3B,GAAKxB,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCZ,EAAOY,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKApB,EAAO,QAAUwB,ICzJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index a0c982c..dcff58c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..40a7576 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 dc56e8c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,280 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 112ab4e..84bdfcf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^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", - "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..78e274e --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 899286c91eeca4d2984dda11922e317cdad07cfb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:47:40 +0000 Subject: [PATCH 057/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 1a36607..dc56e8c 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 // @@ -194,7 +194,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -212,26 +212,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -246,18 +246,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index c929e88..112ab4e 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill": "^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 22433bf047f57d788b3f091a338ea417dbf0d1ce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:17:24 +0000 Subject: [PATCH 058/108] Remove files --- index.d.ts | 213 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5060 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 dcff58c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,213 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 40a7576..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 78e274e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 14359a3d099438555b4a5ff93116d15fbb99b5f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:17:39 +0000 Subject: [PATCH 059/108] 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 | 274 -- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 280 -- package.json | 91 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 ----------- 55 files changed, 4869 insertions(+), 8070 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 (98%) 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 cb07e02..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:24:33.645Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 437e823..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -267,7 +258,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]. @@ -338,9 +329,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 8417b40..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 26200c9..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 56ffb0b..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c17c35b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(B,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),T=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),q=require('@stdlib/iter-length/dist'),k=require('@stdlib/array-defaults/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=T(),M=k.get("dtypes.default");function j(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function V(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a=M,t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return j(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(q(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?V(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=A -});var S=m();module.exports=S; -/** @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 08a4b31..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAQU,EAAOS,CAAI,EAE3B,GAAKxB,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCZ,EAAOY,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKApB,EAAO,QAAUwB,ICzJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index a0c982c..dcff58c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..40a7576 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 dc56e8c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,280 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 112ab4e..84bdfcf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^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", - "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..78e274e --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 60198aecdeddb682ad0020043020eb73f3aece53 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:00:58 +0000 Subject: [PATCH 060/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 1a36607..dc56e8c 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 // @@ -194,7 +194,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -212,26 +212,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -246,18 +246,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index c929e88..112ab4e 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill": "^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 4a2e6282af18297599b117f1ca77b77130876272 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:28:47 +0000 Subject: [PATCH 061/108] Remove files --- index.d.ts | 213 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5060 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 dcff58c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,213 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 40a7576..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 78e274e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cb3dd94c4f0bf0da66469147eba842a004703920 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:29:14 +0000 Subject: [PATCH 062/108] 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 | 274 -- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 280 -- package.json | 91 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 ----------- 54 files changed, 4869 insertions(+), 8071 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 (98%) 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 437e823..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -267,7 +258,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]. @@ -338,9 +329,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 8417b40..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 26200c9..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 56ffb0b..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c17c35b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(B,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),T=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),q=require('@stdlib/iter-length/dist'),k=require('@stdlib/array-defaults/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=T(),M=k.get("dtypes.default");function j(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function V(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a=M,t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return j(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(q(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?V(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=A -});var S=m();module.exports=S; -/** @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 08a4b31..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAQU,EAAOS,CAAI,EAE3B,GAAKxB,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCZ,EAAOY,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKApB,EAAO,QAAUwB,ICzJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index a0c982c..dcff58c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..40a7576 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 dc56e8c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,280 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 112ab4e..84bdfcf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^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", - "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..78e274e --- /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 838dd19..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 544d551e4016b0f93de0d74d64a1124da792aea6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 08:53:52 +0000 Subject: [PATCH 063/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index 1a36607..dc56e8c 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 // @@ -194,7 +194,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -212,26 +212,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -246,18 +246,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 59fe6ae..8371822 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/blas-ext-base-gfill": "^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 ef09e3920dc03e1a3de68f9b6b8a480cc5b91e18 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 09:01:20 +0000 Subject: [PATCH 064/108] Remove files --- index.d.ts | 213 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5060 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 dcff58c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,213 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 40a7576..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 78e274e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 29be3213bbfd8ee588ae9171ad7b044c679aa4ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 09:01:37 +0000 Subject: [PATCH 065/108] 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 | 274 -- benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 157 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 280 -- package.json | 91 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2473 ----------- 54 files changed, 4869 insertions(+), 8078 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 (98%) 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 437e823..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -267,7 +258,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]. @@ -338,9 +329,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 f596671..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,274 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 8faf030..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 e2a2ab0..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c17c35b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var w=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var m=w(function(B,d){ -var h=require('@stdlib/assert-is-string/dist').isPrimitive,g=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),v=require('@stdlib/assert-is-arraybuffer/dist'),y=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/array-ctors/dist'),b=require('@stdlib/blas-ext-base-gfill/dist'),E=require('@stdlib/array-base-filled/dist'),T=require('@stdlib/assert-has-iterator-symbol-support/dist'),s=require('@stdlib/symbol-iterator/dist'),q=require('@stdlib/iter-length/dist'),k=require('@stdlib/array-defaults/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist'),p=T(),M=k.get("dtypes.default");function j(i,e){var a,t;for(a=[];t=i.next(),!t.done;)a.push(e);return a}function V(i,e){var a;for(a=0;a=0&&h(arguments[e])?(a=arguments[e],e-=1):a=M,t=c(a),t===null)throw new TypeError(l('00j2Y',a));if(a==="generic"){if(e<=0)return[];if(i=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:f(r)&&(o=r.length),o!==void 0)return E(i,o);if(v(r))throw new Error(l('00j04'));if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));return j(r,i)}throw new TypeError(l('00j2a',r))}else if(v(r))throw new Error(l('00j04'));throw new TypeError(l('00j2a',r))}if(e<=0)return new t(0);if(e===1)if(r=arguments[1],f(r))n=new t(r.length);else if(v(r))n=new t(r);else if(g(r))n=new t(r);else if(y(r)){if(p===!1)throw new TypeError(l('00j2Z',r));if(!u(r[s]))throw new TypeError(l('00j2a',r));if(r=r[s](),!u(r.next))throw new TypeError(l('00j2a',r));n=new t(q(r))}else throw new TypeError(l('00j2a',r));else e===2?n=new t(arguments[1],arguments[2]):n=new t(arguments[1],arguments[2],arguments[3]);return n.length>0&&(/^complex/.test(a)?V(n,arguments[0]):b(n.length,arguments[0],n,1)),n}d.exports=A -});var S=m();module.exports=S; -/** @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 08a4b31..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) 2020 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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKxB,EAAU,UAAWwB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOpB,EAAOmB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKvB,EAAsB2B,CAAI,EAC9BD,EAAMC,EACK1B,EAAc0B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOnB,EAAQU,EAAOS,CAAI,EAE3B,GAAKxB,EAAeyB,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKxB,EAAUwB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAYzB,EAAeyB,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACvB,EAAYuB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACL,EAAYuB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,EAC3BJ,EAAiBF,EAAK,UAAW,CAAE,CAAE,EAErCZ,EAAOY,EAAI,OAAQ,UAAW,CAAE,EAAGA,EAAK,CAAE,GAGrCA,CACR,CAKApB,EAAO,QAAUwB,ICzJjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 51d3188..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,157 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index a0c982c..dcff58c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..40a7576 --- /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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 dc56e8c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,280 +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. -*/ - -'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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { - filledAccessors( arr, arguments[ 0 ] ); - } else { - gfill( arr.length, arguments[ 0 ], arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 8371822..84bdfcf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^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", - "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..78e274e --- /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 31e86df..0000000 --- a/test/test.js +++ /dev/null @@ -1,2473 +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. -*/ - -'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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 d31b4075f082da4412f488d88a5ef3611f9c1ed7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 29 Jun 2024 06:56:58 +0000 Subject: [PATCH 066/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index df88a74..00aa529 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 4864124..3fd4577 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.1", "@stdlib/iter-length": "^0.2.1", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 ae10c3db7abdee1c734bd3f2f5fdce04b4f1a44c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 29 Jun 2024 06:57:32 +0000 Subject: [PATCH 067/108] Remove files --- index.d.ts | 213 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5060 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 dcff58c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,213 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* 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 (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 40a7576..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 e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as r}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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-gfill@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var a=j(),v=f.get("dtypes.default");function w(){var j,f,w,g,c,b,x;if(f=arguments.length,(f-=1)>=0&&e(arguments[f])?(w=arguments[f],f-=1):w=v,null===(g=o(w)))throw new TypeError(p("00j2Y",w));if("generic"===w){if(f<=0)return[];if(j=arguments[0],x=arguments[1],1===f){if(r(x)?b=x:t(x)&&(b=x.length),void 0!==b)return m(j,b);if(s(x))throw new Error(p("00j04"));if(i(x)){if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(x,j)}throw new TypeError(p("00j2a",x))}if(s(x))throw new Error(p("00j04"));throw new TypeError(p("00j2a",x))}if(f<=0)return new g(0);if(1===f)if(t(x=arguments[1]))c=new g(x.length);else if(s(x))c=new g(x);else if(r(x))c=new g(x);else{if(!i(x))throw new TypeError(p("00j2a",x));if(!1===a)throw new TypeError(p("00j2Z",x));if(!n(x[l]))throw new TypeError(p("00j2a",x));if(x=x[l](),!n(x.next))throw new TypeError(p("00j2a",x));c=new g(h(x))}else c=2===f?new g(arguments[1],arguments[2]):new g(arguments[1],arguments[2],arguments[3]);return c.length>0&&(/^complex/.test(w)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, arguments[ 0 ] );\n\t\t} else {\n\t\t\tgfill( arr.length, arguments[ 0 ], arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","test","i","set","filledAccessors","gfill"],"mappings":";;+zCAwCA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKH,EAAII,OAAS,IACZ,WAAWmB,KAAMzB,GA9LxB,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CAyLGE,CAAiB1B,EAAKG,UAAW,IAEjCwB,EAAO3B,EAAII,OAAQD,UAAW,GAAKH,EAAK,IAGnCA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 78e274e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 41ba374215a1fadba99b4e9b272729263c494a8b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 29 Jun 2024 06:57:56 +0000 Subject: [PATCH 068/108] 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 | 126 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 292 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ------------ 55 files changed, 4870 insertions(+), 8514 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 (98%) 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 437e823..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 2d298f6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,292 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 c9e4209..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,93 +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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 8faf030..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 e2a2ab0..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8045f3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 79a5723..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f5cede3 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import m 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@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import a 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 v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 00aa529..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 3fd4577..84bdfcf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.1", - "@stdlib/iter-length": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..abd6ceb --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 fcc31e5846efa822d799868a2f662a3d30dd6a7e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 7 Mar 2025 22:38:22 +0000 Subject: [PATCH 069/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index a1c8c70..a1078c4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index e9aaecb..c40e95f 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.1", "@stdlib/iter-length": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 217a28278430c3f041d5fe5117197acb8f311808 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 7 Mar 2025 22:38:53 +0000 Subject: [PATCH 070/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f5cede3..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import m 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@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.1-esm/index.mjs";import a 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 v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.2.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index abd6ceb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ea1ce38e36ad7f7025023a41413d4dff347425b8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 7 Mar 2025 22:39:11 +0000 Subject: [PATCH 071/108] 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 | 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 | 276 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 292 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ---------- 56 files changed, 4870 insertions(+), 8774 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 (98%) 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 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 2d298f6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,292 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 c9e4209..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,93 +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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 8faf030..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 e2a2ab0..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8045f3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 4ab487d..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|Complex64Array)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7ba7c83 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import m 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@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 a1078c4..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|Complex64Array)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index c40e95f..84bdfcf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..750d385 --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 2f85523004192a50166a2d4d73420f187d5147ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Apr 2025 00:11:20 +0000 Subject: [PATCH 072/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index df88a74..00aa529 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index e9aaecb..c40e95f 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.1", "@stdlib/iter-length": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 3cd1746eba8d3dff8df83ea204fea5997ab65b25 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Apr 2025 00:11:37 +0000 Subject: [PATCH 073/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7ba7c83..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import m 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@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 750d385..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 560877cdbe24521ffd34b682e6565402a79a1b83 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Apr 2025 00:12:48 +0000 Subject: [PATCH 074/108] 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 | 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 | 278 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 292 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ---------- 56 files changed, 4870 insertions(+), 8776 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 (98%) 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 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 2d298f6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,292 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 c9e4209..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,93 +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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 8faf030..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 e2a2ab0..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8045f3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 79a5723..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7ba7c83 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import m 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@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 00aa529..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index c40e95f..84bdfcf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..ff8cfb3 --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 688e4f2833505df2d2734794a2dae3084984d013 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 03:35:43 +0000 Subject: [PATCH 075/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index df88a74..00aa529 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 067d7c7..176372d 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.1", "@stdlib/iter-length": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 90b07944b50ac03fe2db4207371cac1fb7dbc14e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 05:15:20 +0000 Subject: [PATCH 076/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7ba7c83..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import m 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@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ff8cfb3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 606888cf58ed3b9668db5376c391343f966f0873 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 05:15:45 +0000 Subject: [PATCH 077/108] 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 | 278 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 292 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ---------- 56 files changed, 4870 insertions(+), 8881 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 (98%) 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 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 2d298f6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,292 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 c9e4209..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,93 +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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 8faf030..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 e2a2ab0..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8045f3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 79a5723..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..60d9b16 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import m 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@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.0-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 00aa529..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 176372d..a71a623 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.1", - "@stdlib/iter-length": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..050253a --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 f2ea5a94b3195f34e41710d5ab82b91f6a299a52 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 05:56:17 +0000 Subject: [PATCH 078/108] 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 3bc6840..97f28dc 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.3.0-esm/index.mjs'; ``` #### filledarray( \[dtype] ) @@ -186,7 +186,7 @@ arr = filledarray( 1, buf, 10, 4, 'int16' ); import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.3.0-esm/index.mjs'; // Generate a random number: var r = discreteUniform( 0, 100 ); From e03a039689d3409f1a7a550ccc99f3d776c09b82 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 05:56:17 +0000 Subject: [PATCH 079/108] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 97f28dc..f3fe39e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@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/tags). For example, + ```javascript import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.3.0-esm/index.mjs'; ``` @@ -186,7 +191,7 @@ arr = filledarray( 1, buf, 10, 4, 'int16' ); import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.3.0-esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; // Generate a random number: var r = discreteUniform( 0, 100 ); From 84911dd425d88acd3b0f55fc93ff6b0c51552f78 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 20:35:39 +0000 Subject: [PATCH 080/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index df88a74..00aa529 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index 1718dd3..2625a6e 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.3", "@stdlib/iter-length": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 582a305bb63289d4f4c352c97761caa74cdad103 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 21:49:23 +0000 Subject: [PATCH 081/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 60d9b16..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import m 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@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.0-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 050253a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 588331435d4b4756c9f8c916fc8794aeb15f4fd5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 21:49:45 +0000 Subject: [PATCH 082/108] 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 | 288 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 292 -- benchmark/benchmark.length.bool.js | 93 - benchmark/benchmark.length.complex128.js | 97 - benchmark/benchmark.length.complex64.js | 97 - benchmark/benchmark.length.float32.js | 93 - benchmark/benchmark.length.float64.js | 93 - benchmark/benchmark.length.generic.js | 93 - benchmark/benchmark.length.int16.js | 93 - benchmark/benchmark.length.int32.js | 93 - benchmark/benchmark.length.int8.js | 93 - benchmark/benchmark.length.uint16.js | 93 - benchmark/benchmark.length.uint32.js | 93 - benchmark/benchmark.length.uint8.js | 93 - benchmark/benchmark.length.uint8c.js | 93 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ---------- 56 files changed, 4870 insertions(+), 8884 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 (98%) 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 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 2d298f6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,292 +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. -*/ - -'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 Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should 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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 c9e4209..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,93 +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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 8faf030..0000000 --- a/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 e2a2ab0..0000000 --- a/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d4c1a2b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 a487905..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 d62f1d0..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 54f62e5..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c41b56b..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 ef22925..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 c1ad10a..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 6b4371e..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 9d1b9b5..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 f11b159..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'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 pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8045f3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 79a5723..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a81ab93 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 00aa529..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 2625a6e..c9e19ae 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..1b46186 --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 682e8e8622b2d9276c7c954a9b71dc4fdfe1a7dd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 22:24:01 +0000 Subject: [PATCH 083/108] 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 090b769..85ee507 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.3.1-esm/index.mjs'; ``` #### filledarray( \[dtype] ) @@ -186,7 +186,7 @@ arr = filledarray( 1, buf, 10, 4, 'int16' ); import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.3.1-esm/index.mjs'; // Generate a random number: var r = discreteUniform( 0, 100 ); From 96c5759f0c587ba6f620d45f2bdb804fcfd08fe7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 22:24:02 +0000 Subject: [PATCH 084/108] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 85ee507..1fd5c9e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@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/tags). For example, + ```javascript import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.3.1-esm/index.mjs'; ``` @@ -186,7 +191,7 @@ arr = filledarray( 1, buf, 10, 4, 'int16' ); import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-real-dtypes@esm/index.mjs'; -import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@v0.3.1-esm/index.mjs'; +import filledarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-filled@esm/index.mjs'; // Generate a random number: var r = discreteUniform( 0, 100 ); From 436e26b3718649f55e8a93eae1e7766151f8ec3d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 19:28:40 +0000 Subject: [PATCH 085/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index df88a74..00aa529 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index ed7deca..33a96f6 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.3", "@stdlib/iter-length": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 0c54c9327a04249c5893884de217c692c684d453 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 19:29:24 +0000 Subject: [PATCH 086/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a81ab93..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1b46186..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b7254cf71053399cfb3faf826c0d21da1072fc90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 19:29:51 +0000 Subject: [PATCH 087/108] 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 | 322 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 293 -- benchmark/benchmark.length.bool.js | 94 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 94 - benchmark/benchmark.length.float64.js | 94 - benchmark/benchmark.length.generic.js | 94 - benchmark/benchmark.length.int16.js | 94 - benchmark/benchmark.length.int32.js | 94 - benchmark/benchmark.length.int8.js | 94 - benchmark/benchmark.length.uint16.js | 94 - benchmark/benchmark.length.uint32.js | 94 - benchmark/benchmark.length.uint8.js | 94 - benchmark/benchmark.length.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ---------- 56 files changed, 4870 insertions(+), 8932 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 (98%) 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 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 89887eb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,293 +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. -*/ - -'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 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 filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 83f3721..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,94 +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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 dba69d3..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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 d7ebcfd..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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d262b8b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 1ad9a50..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 b07b7af..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 55e2601..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 9b275c1..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 afb10a1..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 13b1cb5..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 54eec27..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 ea4f536..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 c671414..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8045f3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 79a5723..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d937b16 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 00aa529..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 33a96f6..c9e19ae 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..2c411ca --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 5f9e09fec5544ed40c4af02d82715b8447b0e07e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 02:45:25 +0000 Subject: [PATCH 088/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index df88a74..00aa529 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index ed7deca..33a96f6 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.3", "@stdlib/iter-length": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 93014b6744ddfab541a0783250faeaa25df2f371 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 04:30:03 +0000 Subject: [PATCH 089/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d937b16..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2c411ca..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fcade3c58c8a6f471e64a9ee8518a2608cfd9b2a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 04:30:27 +0000 Subject: [PATCH 090/108] 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 | 322 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 293 -- benchmark/benchmark.length.bool.js | 94 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 94 - benchmark/benchmark.length.float64.js | 94 - benchmark/benchmark.length.generic.js | 94 - benchmark/benchmark.length.int16.js | 94 - benchmark/benchmark.length.int32.js | 94 - benchmark/benchmark.length.int8.js | 94 - benchmark/benchmark.length.uint16.js | 94 - benchmark/benchmark.length.uint32.js | 94 - benchmark/benchmark.length.uint8.js | 94 - benchmark/benchmark.length.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ---------- 57 files changed, 4870 insertions(+), 8933 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 (98%) 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 7f8b128..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-16T02:04:27.331Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 89887eb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,293 +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. -*/ - -'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 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 filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 83f3721..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,94 +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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 dba69d3..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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 d7ebcfd..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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d262b8b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 1ad9a50..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 b07b7af..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 55e2601..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 9b275c1..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 afb10a1..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 13b1cb5..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 54eec27..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 ea4f536..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 c671414..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8045f3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 79a5723..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..34eaf74 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import m 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@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var b=p(),c=g.get("dtypes.default");function v(){var p,g,v,x,y,u,E;if(g=arguments.length,(g-=1)>=0&&t(arguments[g])?(v=arguments[g],g-=1):v=c,null===(x=m(v)))throw new TypeError(w("00j2Y",v));if("generic"===v){if(g<=0)return[];if(p=arguments[0],E=arguments[1],1===g){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(w("00j04"));if(o(E)){if(!1===b)throw new TypeError(w("00j2Z",E));if(!d(E[a]))throw new TypeError(w("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(w("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(w("00j2a",E))}if(n(E))throw new Error(w("00j04"));throw new TypeError(w("00j2a",E))}if(g<=0)return new x(0);if(1===g)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(w("00j2a",E));if(!1===b)throw new TypeError(w("00j2Z",E));if(!d(E[a]))throw new TypeError(w("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(w("00j2a",E));y=new x(f(E))}else y=2===g?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(v)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;oiDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 00aa529..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 33a96f6..c9e19ae 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..018669a --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 97bd5bc9e8abcbb05e32af394047e7c9e0459b44 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 6 Apr 2026 03:48:56 +0000 Subject: [PATCH 091/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index df88a74..00aa529 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index ed7deca..33a96f6 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.3", "@stdlib/iter-length": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 26b3a12b15cb1d3ef02f769e485b702b5b28525b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 6 Apr 2026 04:03:35 +0000 Subject: [PATCH 092/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 34eaf74..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import m 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@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var b=p(),c=g.get("dtypes.default");function v(){var p,g,v,x,y,u,E;if(g=arguments.length,(g-=1)>=0&&t(arguments[g])?(v=arguments[g],g-=1):v=c,null===(x=m(v)))throw new TypeError(w("00j2Y",v));if("generic"===v){if(g<=0)return[];if(p=arguments[0],E=arguments[1],1===g){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(w("00j04"));if(o(E)){if(!1===b)throw new TypeError(w("00j2Z",E));if(!d(E[a]))throw new TypeError(w("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(w("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(w("00j2a",E))}if(n(E))throw new Error(w("00j04"));throw new TypeError(w("00j2a",E))}if(g<=0)return new x(0);if(1===g)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(w("00j2a",E));if(!1===b)throw new TypeError(w("00j2Z",E));if(!d(E[a]))throw new TypeError(w("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(w("00j2a",E));y=new x(f(E))}else y=2===g?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(v)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;oiDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 018669a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4692696bb84f5bb197576b08f5a6344ea72cf799 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 6 Apr 2026 04:03:57 +0000 Subject: [PATCH 093/108] 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 | 322 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 293 -- benchmark/benchmark.length.bool.js | 94 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 94 - benchmark/benchmark.length.float64.js | 94 - benchmark/benchmark.length.generic.js | 94 - benchmark/benchmark.length.int16.js | 94 - benchmark/benchmark.length.int32.js | 94 - benchmark/benchmark.length.int8.js | 94 - benchmark/benchmark.length.uint16.js | 94 - benchmark/benchmark.length.uint32.js | 94 - benchmark/benchmark.length.uint8.js | 94 - benchmark/benchmark.length.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ---------- 57 files changed, 4870 insertions(+), 8944 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 (98%) 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 2e3be9a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-06T03:38:05.973Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 89887eb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,293 +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. -*/ - -'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 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 filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 83f3721..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,94 +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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 dba69d3..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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 d7ebcfd..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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d262b8b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 1ad9a50..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 b07b7af..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 55e2601..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 9b275c1..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 afb10a1..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 13b1cb5..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 54eec27..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 ea4f536..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 c671414..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8045f3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 79a5723..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d937b16 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 00aa529..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 33a96f6..c9e19ae 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..2c411ca --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 eca6fb31e95c1c9bc159e5fee254a7ea8ab9da68 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 14 May 2026 03:38:39 +0000 Subject: [PATCH 094/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index df88a74..00aa529 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index ed7deca..33a96f6 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.3", "@stdlib/iter-length": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 9b64d8acd89720997f99e6ed46f9cfec6d97a4ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 14 May 2026 03:52:30 +0000 Subject: [PATCH 095/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d937b16..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2c411ca..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e9e29683241d48552948b0ca0fc65f3b5c7072f5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 14 May 2026 03:52:47 +0000 Subject: [PATCH 096/108] 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 | 322 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 293 -- benchmark/benchmark.length.bool.js | 94 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 94 - benchmark/benchmark.length.float64.js | 94 - benchmark/benchmark.length.generic.js | 94 - benchmark/benchmark.length.int16.js | 94 - benchmark/benchmark.length.int32.js | 94 - benchmark/benchmark.length.int8.js | 94 - benchmark/benchmark.length.uint16.js | 94 - benchmark/benchmark.length.uint32.js | 94 - benchmark/benchmark.length.uint8.js | 94 - benchmark/benchmark.length.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ---------- 57 files changed, 4870 insertions(+), 8949 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 (98%) 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 eadcaa1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-14T03:35:09.220Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 89887eb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,293 +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. -*/ - -'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 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 filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 83f3721..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,94 +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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 dba69d3..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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 d7ebcfd..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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d262b8b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 1ad9a50..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 b07b7af..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 55e2601..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 9b275c1..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 afb10a1..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 13b1cb5..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 54eec27..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 ea4f536..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 c671414..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b8045f3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 79a5723..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d937b16 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 00aa529..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 33a96f6..c9e19ae 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..2c411ca --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 cc4aba3bd47770f336a7959ff0196d5da252d0e3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jun 2026 03:40:22 +0000 Subject: [PATCH 097/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index df88a74..00aa529 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -197,7 +197,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -215,26 +215,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -249,18 +249,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index dd1b13e..3e6513f 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.3", "@stdlib/iter-length": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 26a8f5746a2a6537b57487803f3001453baa46ae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jun 2026 03:56:35 +0000 Subject: [PATCH 098/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d937b16..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2c411ca..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 951987cbed93bf6593c0ddab637d7673cce649ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jun 2026 03:57:01 +0000 Subject: [PATCH 099/108] 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 | 322 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 293 -- benchmark/benchmark.length.bool.js | 94 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float32.js | 94 - benchmark/benchmark.length.float64.js | 94 - benchmark/benchmark.length.generic.js | 94 - benchmark/benchmark.length.int16.js | 94 - benchmark/benchmark.length.int32.js | 94 - benchmark/benchmark.length.int8.js | 94 - benchmark/benchmark.length.uint16.js | 94 - benchmark/benchmark.length.uint32.js | 94 - benchmark/benchmark.length.uint8.js | 94 - benchmark/benchmark.length.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 132 - lib/main.js | 286 -- package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2665 ---------- 57 files changed, 4870 insertions(+), 8962 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 (98%) 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 c3d1fda..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-06-27T03:35:10.830Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 89887eb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,293 +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. -*/ - -'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 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 filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 83f3721..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,94 +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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 dba69d3..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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 d7ebcfd..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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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 d262b8b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 1ad9a50..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 b07b7af..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 55e2601..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 9b275c1..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 afb10a1..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 13b1cb5..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 54eec27..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 ea4f536..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 c671414..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0fd78cc..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){try{return e||t((e={exports:{}}).exports,e),e.exports}catch(a){throw e=0,a}}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 75bcfd2..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CA8FA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC/JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 7d17e3f..c08a1ab 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d937b16 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ca37401..0000000 --- a/lib/index.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 00aa529..0000000 --- a/lib/main.js +++ /dev/null @@ -1,286 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index 3e6513f..c9e19ae 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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,74 +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": "^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": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..2c411ca --- /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 cdb6eeb..0000000 --- a/test/test.js +++ /dev/null @@ -1,2665 +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 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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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 (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 7d0e8bf88d396c843e6be7ce2b05c54a3fd4b1be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 19:58:54 +0000 Subject: [PATCH 100/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index e2afa1c..dd6bb5b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -201,7 +201,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -219,26 +219,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -253,18 +253,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b33ea0a..d4823cc 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.3", "@stdlib/iter-length": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 c94707b9ffd81068065a660cae053ff6af65cf20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 19:59:16 +0000 Subject: [PATCH 101/108] Remove files --- index.d.ts | 198 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5045 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 c08a1ab..0000000 --- a/index.d.ts +++ /dev/null @@ -1,198 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d937b16..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBAwIlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OA7KJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAgKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GA/L1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA0LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2c411ca..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d5750bb54b1dd272fdfb9d2cb36812980f79739e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 20:00:00 +0000 Subject: [PATCH 102/108] 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 | 335 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 311 -- benchmark/benchmark.length.bool.js | 94 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float16.js | 95 - benchmark/benchmark.length.float32.js | 94 - benchmark/benchmark.length.float64.js | 94 - benchmark/benchmark.length.generic.js | 94 - benchmark/benchmark.length.int16.js | 94 - benchmark/benchmark.length.int32.js | 94 - benchmark/benchmark.length.int8.js | 94 - benchmark/benchmark.length.uint16.js | 94 - benchmark/benchmark.length.uint32.js | 94 - benchmark/benchmark.length.uint8.js | 94 - benchmark/benchmark.length.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 138 - lib/main.js | 290 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2822 ---------- 57 files changed, 4870 insertions(+), 9255 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.float16.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 (98%) 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 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 04b799e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,311 +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. -*/ - -'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 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 filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.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=float16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 83f3721..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,94 +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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 dba69d3..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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 d7ebcfd..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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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.float16.js b/benchmark/benchmark.length.float16.js deleted file mode 100644 index a4d41eb..0000000 --- a/benchmark/benchmark.length.float16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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=float16,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 d262b8b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 1ad9a50..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 b07b7af..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 55e2601..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 9b275c1..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 afb10a1..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 13b1cb5..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 54eec27..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 ea4f536..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 c671414..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0fd78cc..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){try{return e||t((e={exports:{}}).exports,e),e.exports}catch(a){throw e=0,a}}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 62793d1..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CAkGA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC7JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 205f236..bfca44e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d937b16 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA4IlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAjLJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAoKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GAnM1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA8LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3ece0cd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,138 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float16' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 dd6bb5b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,290 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float16' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index d4823cc..c9e19ae 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-float16": "github:stdlib-js/array-float16#main", - "@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-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..21f460f --- /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 f5d1025..0000000 --- a/test/test.js +++ /dev/null @@ -1,2822 +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'; - -/* eslint-disable max-lines */ - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float16Array = require( '@stdlib/array-float16' ); -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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=float16)', function test( t ) { - var expected; - var arr; - - expected = new Float16Array( 0 ); - - arr = filledarray( 'float16' ); - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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=float16, length)', function test( t ) { - var expected; - var arr; - - expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float16' ); - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=float16, length)', function test( t ) { - var expected; - var arr; - - expected = new Float16Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float16' ); - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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=float16, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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=float16, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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=float16, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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=float16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 2, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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=float16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float16Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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=float16, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 7e143b1ce8a3c24c79e93e1dff7c78f5a83270ae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Jul 2026 22:42:22 +0000 Subject: [PATCH 103/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index e2afa1c..dd6bb5b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -201,7 +201,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -219,26 +219,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -253,18 +253,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b33ea0a..d4823cc 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.3", "@stdlib/iter-length": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 26bb3380defbbfd8d741b9d16409e1f95f3ce411 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Jul 2026 22:42:42 +0000 Subject: [PATCH 104/108] Remove files --- index.d.ts | 240 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5087 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 bfca44e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,240 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -* -* @example -* var arr = filledarray( 'float16' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float16' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float16' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float16' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float16' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float16' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float16' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d937b16..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA4IlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAjLJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAoKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GAnM1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA8LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 21f460f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 090e0c2a120b026bea9cff34d5ca6ee50f71e2c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Jul 2026 22:43:15 +0000 Subject: [PATCH 105/108] 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 | 337 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 311 -- benchmark/benchmark.length.bool.js | 94 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float16.js | 94 - benchmark/benchmark.length.float32.js | 94 - benchmark/benchmark.length.float64.js | 94 - benchmark/benchmark.length.generic.js | 94 - benchmark/benchmark.length.int16.js | 94 - benchmark/benchmark.length.int32.js | 94 - benchmark/benchmark.length.int8.js | 94 - benchmark/benchmark.length.uint16.js | 94 - benchmark/benchmark.length.uint32.js | 94 - benchmark/benchmark.length.uint8.js | 94 - benchmark/benchmark.length.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 138 - lib/main.js | 290 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2822 ---------- 57 files changed, 4870 insertions(+), 9256 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.float16.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 (98%) 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 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 04b799e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,311 +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. -*/ - -'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 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 filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.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=float16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 83f3721..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,94 +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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 dba69d3..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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 d7ebcfd..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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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.float16.js b/benchmark/benchmark.length.float16.js deleted file mode 100644 index e7ece16..0000000 --- a/benchmark/benchmark.length.float16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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=float16,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 d262b8b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 1ad9a50..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 b07b7af..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 55e2601..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 9b275c1..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 afb10a1..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 13b1cb5..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 54eec27..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 ea4f536..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 c671414..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0fd78cc..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){try{return e||t((e={exports:{}}).exports,e),e.exports}catch(a){throw e=0,a}}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 62793d1..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CAkGA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC7JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 205f236..bfca44e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d937b16 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA4IlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAjLJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAoKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GAnM1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA8LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3ece0cd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,138 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float16' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 dd6bb5b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,290 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float16' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index d4823cc..c9e19ae 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-float16": "github:stdlib-js/array-float16#main", - "@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-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..21f460f --- /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 f5d1025..0000000 --- a/test/test.js +++ /dev/null @@ -1,2822 +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'; - -/* eslint-disable max-lines */ - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float16Array = require( '@stdlib/array-float16' ); -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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=float16)', function test( t ) { - var expected; - var arr; - - expected = new Float16Array( 0 ); - - arr = filledarray( 'float16' ); - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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=float16, length)', function test( t ) { - var expected; - var arr; - - expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float16' ); - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=float16, length)', function test( t ) { - var expected; - var arr; - - expected = new Float16Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float16' ); - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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=float16, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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=float16, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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=float16, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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=float16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 2, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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=float16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float16Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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=float16, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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 b8ed477bb0f90e2ff93165634399a9ed6a3834c1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 15 Aug 2026 02:56:44 +0000 Subject: [PATCH 106/108] Transform error messages --- lib/main.js | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/main.js b/lib/main.js index e2afa1c..dd6bb5b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -36,7 +36,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 // @@ -201,7 +201,7 @@ function filledarray() { } 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( '00j2Y', dtype ) ); } if ( dtype === 'generic' ) { if ( nargs <= 0 ) { @@ -219,26 +219,26 @@ function filledarray() { return filled( value, len ); } if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } 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( '00j2Z', 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( '00j2a', 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( '00j2a', arg ) ); } return filledIterator( arg, value ); } - 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( '00j2a', arg ) ); } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + throw new Error( format('00j04') ); } - 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( '00j2a', arg ) ); } if ( nargs <= 0 ) { return new ctor( 0 ); @@ -253,18 +253,18 @@ function filledarray() { 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( '00j2Z', 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( '00j2a', 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( '00j2a', 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( '00j2a', arg ) ); } } else if ( nargs === 2 ) { arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) diff --git a/package.json b/package.json index b33ea0a..d4823cc 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/blas-ext-base-gfill": "^0.2.3", "@stdlib/iter-length": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.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 3008dd86780be95c54af2a6fd5f779d0afa1bc7f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 15 Aug 2026 03:28:16 +0000 Subject: [PATCH 107/108] Remove files --- index.d.ts | 240 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5087 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 bfca44e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,240 +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 @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -* -* @example -* var arr = filledarray( 'float16' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float16' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float16' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter-constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float16' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float16' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float16' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float16' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d937b16..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA4IlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAjLJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAoKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GAnM1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA8LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 21f460f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7e1b1b43748434ab5b0358b88723e7c9930cdf94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 15 Aug 2026 03:28:41 +0000 Subject: [PATCH 108/108] 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 | 337 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 311 -- benchmark/benchmark.length.bool.js | 94 - benchmark/benchmark.length.complex128.js | 98 - benchmark/benchmark.length.complex64.js | 98 - benchmark/benchmark.length.float16.js | 94 - benchmark/benchmark.length.float32.js | 94 - benchmark/benchmark.length.float64.js | 94 - benchmark/benchmark.length.generic.js | 94 - benchmark/benchmark.length.int16.js | 94 - benchmark/benchmark.length.int32.js | 94 - benchmark/benchmark.length.int8.js | 94 - benchmark/benchmark.length.uint16.js | 94 - benchmark/benchmark.length.uint32.js | 94 - benchmark/benchmark.length.uint8.js | 94 - benchmark/benchmark.length.uint8c.js | 94 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 140 - docs/types/test.ts | 200 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 138 - lib/main.js | 290 -- package.json | 96 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 2822 ---------- 58 files changed, 4870 insertions(+), 9258 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.float16.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 (98%) 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 3350a8a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-15T02:42:15.196Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 36b2805..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) 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 51c690b..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) 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 2743b4c..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: '45 21 * * 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 + + ```
@@ -252,7 +243,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]. @@ -321,13 +312,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-by]: https://github.com/stdlib-js/array-filled-by +[@stdlib/array/filled-by]: https://github.com/stdlib-js/array-filled-by/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 04b799e..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,311 +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. -*/ - -'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 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 filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.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=float16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.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 arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.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 arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - 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 83f3721..0000000 --- a/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,94 +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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - 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 dba69d3..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 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 arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - 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 d7ebcfd..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 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 arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - 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.float16.js b/benchmark/benchmark.length.float16.js deleted file mode 100644 index e7ece16..0000000 --- a/benchmark/benchmark.length.float16.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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=float16,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 d262b8b..0000000 --- a/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 1ad9a50..0000000 --- a/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 b07b7af..0000000 --- a/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - 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 55e2601..0000000 --- a/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 9b275c1..0000000 --- a/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 afb10a1..0000000 --- a/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing 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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 13b1cb5..0000000 --- a/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 54eec27..0000000 --- a/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 ea4f536..0000000 --- a/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 c671414..0000000 --- a/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,94 +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. -*/ - -'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 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 arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - 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 548cefd..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" -%% click B href "https://github.com/stdlib-js/array-filled/tree/main" -%% click C href "https://github.com/stdlib-js/array-filled/tree/production" -%% click D href "https://github.com/stdlib-js/array-filled/tree/esm" -%% click E href "https://github.com/stdlib-js/array-filled/tree/deno" -%% click F href "https://github.com/stdlib-js/array-filled/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled -[production-url]: https://github.com/stdlib-js/array-filled/tree/production -[deno-url]: https://github.com/stdlib-js/array-filled/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-filled/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-filled/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-filled/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-filled/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-filled/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 b52b5be..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import filledarray from '../docs/types/index'; -export = filledarray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0fd78cc..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var w=function(t,e){return function(){try{return e||t((e={exports:{}}).exports,e),e.exports}catch(a){throw e=0,a}}};var h=w(function(C,m){"use strict";var c=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),b=require("@stdlib/array-base-assert-is-boolean-data-type"),q=require("@stdlib/assert-is-string").isPrimitive,g=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,y=require("@stdlib/assert-is-collection"),v=require("@stdlib/assert-is-arraybuffer"),f=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),E=require("@stdlib/array-ctors"),p=require("@stdlib/blas-ext-base-gfill"),T=require("@stdlib/array-base-filled"),k=require("@stdlib/strided-base-reinterpret-boolean"),M=require("@stdlib/assert-has-iterator-symbol-support"),s=require("@stdlib/symbol-iterator"),j=require("@stdlib/iter-length"),V=require("@stdlib/array-defaults"),l=require("@stdlib/string-format"),d=M(),A=V.get("dtypes.default");function S(t,e){var a,n;for(a=[];n=t.next(),!n.done;)a.push(e);return a}function B(t,e){var a;for(a=0;a=0&&q(arguments[e])?(a=arguments[e],e-=1):a=A,n=E(a),n===null)throw new TypeError(l("invalid argument. Must provide a recognized data type. Value: `%s`.",a));if(a==="generic"){if(e<=0)return[];if(t=arguments[0],r=arguments[1],e===1){if(g(r)?o=r:y(r)&&(o=r.length),o!==void 0)return T(t,o);if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return S(r,t)}throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(v(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e<=0)return new n(0);if(e===1)if(r=arguments[1],y(r))i=new n(r.length);else if(v(r))i=new n(r);else if(g(r))i=new n(r);else if(f(r)){if(d===!1)throw new TypeError(l("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[s]))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[s](),!u(r.next))throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));i=new n(j(r))}else throw new TypeError(l("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===2?i=new n(arguments[1],arguments[2]):i=new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(t=arguments[0],c(a)?B(i,t):b(a)?p(i.length,t?1:0,k(i,0),1):p(i.length,t,i,1)),i}m.exports=x});var I=h();module.exports=I; -/** -* @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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 62793d1..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) 2020 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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\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 gfill = require( '@stdlib/blas-ext-base-gfill' );\nvar filled = require( '@stdlib/array-base-filled' );\nvar reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' );\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 {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\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 {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\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* @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 {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\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 filledIterator( arg, value );\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 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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 === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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.\n*\n* @module @stdlib/array-filled\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 2, arr1, 'uint32' );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarray = require( '@stdlib/array-filled' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\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,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,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,EAAQ,QAAS,6BAA8B,EAC/CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAkB,QAAS,0CAA2C,EACtEC,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,EAanD,SAASI,EAAgBC,EAAIC,EAAQ,CACpC,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIH,EAAG,KAAK,EACP,CAAAG,EAAE,MAGPD,EAAI,KAAMD,CAAM,EAEjB,OAAOC,CACR,CAUA,SAASE,EAAiBF,EAAKD,EAAQ,CACtC,IAAII,EACJ,IAAMA,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5BH,EAAI,IAAKD,EAAOI,CAAE,EAEnB,OAAOH,CACR,CAkGA,SAASI,GAAc,CACtB,IAAIL,EACAM,EACAC,EACAC,EACAP,EACAQ,EACAC,EAWJ,GATAJ,EAAQ,UAAU,OAClBA,GAAS,EACJA,GAAS,GAAKzB,EAAU,UAAWyB,CAAM,CAAE,GAC/CC,EAAQ,UAAWD,CAAM,EACzBA,GAAS,GAETC,EAAQV,EAETW,EAAOrB,EAAOoB,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,sEAAuEY,CAAM,CAAE,EAE7G,GAAKA,IAAU,UAAY,CAC1B,GAAKD,GAAS,EACb,MAAO,CAAC,EAIT,GAFAN,EAAQ,UAAW,CAAE,EACrBU,EAAM,UAAW,CAAE,EACdJ,IAAU,EAAI,CAMlB,GALKxB,EAAsB4B,CAAI,EAC9BD,EAAMC,EACK3B,EAAc2B,CAAI,IAC7BD,EAAMC,EAAI,QAEND,IAAQ,OACZ,OAAOpB,EAAQW,EAAOS,CAAI,EAE3B,GAAKzB,EAAe0B,CAAI,EACvB,MAAM,IAAI,MAAO,mFAAoF,EAEtG,GAAKzB,EAAUyB,CAAI,EAAI,CACtB,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7I,OAAOZ,EAAgBY,EAAKV,CAAM,CACnC,CACA,MAAM,IAAI,UAAWL,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,SAAY1B,EAAe0B,CAAI,EAC9B,MAAM,IAAI,MAAO,mFAAoF,EAEtG,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,CAC7I,CACA,GAAKJ,GAAS,EACb,OAAO,IAAIE,EAAM,CAAE,EAEpB,GAAKF,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,GAAKd,IAAwB,GAC5B,MAAM,IAAI,UAAWD,EAAQ,sIAAuIe,CAAI,CAAE,EAE3K,GAAK,CAACxB,EAAYwB,EAAKlB,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWG,EAAQ,wGAAyGe,CAAI,CAAE,EAG7I,GADAA,EAAMA,EAAKlB,CAAgB,EAAE,EACxB,CAACN,EAAYwB,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWf,EAAQ,wGAAyGe,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMf,EAAYiB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWf,EAAQ,wGAAyGe,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,IACjBD,EAAQ,UAAW,CAAE,EAChBrB,EAAmB4B,CAAM,EAC7BJ,EAAiBF,EAAKD,CAAM,EACjBpB,EAAmB2B,CAAM,EACpCnB,EAAOa,EAAI,OAAUD,EAAU,EAAI,EAAGV,EAAiBW,EAAK,CAAE,EAAG,CAAE,EAEnEb,EAAOa,EAAI,OAAQD,EAAOC,EAAK,CAAE,GAG5BA,CACR,CAKAvB,EAAO,QAAU2B,IC7JjB,IAAIM,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfill", "filled", "reinterpretBool", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledIterator", "it", "value", "arr", "v", "filledAccessors", "i", "filledarray", "nargs", "dtype", "ctor", "len", "arg", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 47742a8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,140 +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}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - 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'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 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 4da77fe..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $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 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 2841d19..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var dtypes = require( '@stdlib/array-typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = 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 = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 205f236..bfca44e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, DataTypeMap } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d937b16 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.2-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import m 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@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/iter-length@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";var w=p(),b=v.get("dtypes.default");function c(){var p,v,c,x,y,u,E;if(v=arguments.length,(v-=1)>=0&&t(arguments[v])?(c=arguments[v],v-=1):c=b,null===(x=m(c)))throw new TypeError(g("00j2Y",c));if("generic"===c){if(v<=0)return[];if(p=arguments[0],E=arguments[1],1===v){if(s(E)?u=E:i(E)&&(u=E.length),void 0!==u)return j(p,u);if(n(E))throw new Error(g("00j04"));if(o(E)){if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));return function(e,r){var t;for(t=[];!e.next().done;)t.push(r);return t}(E,p)}throw new TypeError(g("00j2a",E))}if(n(E))throw new Error(g("00j04"));throw new TypeError(g("00j2a",E))}if(v<=0)return new x(0);if(1===v)if(i(E=arguments[1]))y=new x(E.length);else if(n(E))y=new x(E);else if(s(E))y=new x(E);else{if(!o(E))throw new TypeError(g("00j2a",E));if(!1===w)throw new TypeError(g("00j2Z",E));if(!d(E[a]))throw new TypeError(g("00j2a",E));if(E=E[a](),!d(E.next))throw new TypeError(g("00j2a",E));y=new x(f(E))}else y=2===v?new x(arguments[1],arguments[2]):new x(arguments[1],arguments[2],arguments[3]);return y.length>0&&(p=arguments[0],e(c)?function(e,r){var t;for(t=0;t\n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float16' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\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( '00j2Y', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\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 filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( format('00j04') );\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( '00j2Z', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( format('00j04') );\n\t\t}\n\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\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( '00j2Z', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( '00j2a', 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( '00j2a', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( '00j2a', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","DEFAULT_DTYPE","defaults","get","filledarray","value","nargs","dtype","ctor","arr","len","arg","arguments","length","isString","ctors","TypeError","format","isNonNegativeInteger","isCollection","filled","isArrayBuffer","Error","isObject","isFunction","ITERATOR_SYMBOL","next","it","done","push","filledIterator","iterLength","isComplexDataType","i","set","filledAccessors","isBooleanDataType","gfill","reinterpretBool"],"mappings":";;2pDA2CA,IAAIA,EAAsBC,IACtBC,EAAgBC,EAASC,IAAK,kBA4IlC,SAASC,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,GATAL,EAAQM,UAAUC,QAClBP,GAAS,IACK,GAAKQ,EAAUF,UAAWN,KACvCC,EAAQK,UAAWN,GACnBA,GAAS,GAETC,EAAQN,EAGK,QADdO,EAAOO,EAAOR,IAEb,MAAM,IAAIS,UAAWC,EAAQ,QAASV,IAEvC,GAAe,YAAVA,EAAsB,CAC1B,GAAKD,GAAS,EACb,MAAO,GAIR,GAFAD,EAAQO,UAAW,GACnBD,EAAMC,UAAW,GACF,IAAVN,EAAc,CAMlB,GALKY,EAAsBP,GAC1BD,EAAMC,EACKQ,EAAcR,KACzBD,EAAMC,EAAIE,aAEE,IAARH,EACJ,OAAOU,EAAQf,EAAOK,GAEvB,GAAKW,EAAeV,GACnB,MAAM,IAAIW,MAAOL,EAAO,UAEzB,GAAKM,EAAUZ,GAAQ,CACtB,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvC,OAjLJ,SAAyBgB,EAAItB,GAC5B,IAAII,EAIJ,IADAA,EAAM,IAEDkB,EAAGD,OACAE,MAGPnB,EAAIoB,KAAMxB,GAEX,OAAOI,CACR,CAoKWqB,CAAgBnB,EAAKN,EAC5B,CACD,MAAM,IAAIW,UAAWC,EAAQ,QAASN,GACzC,CAAS,GAAKU,EAAeV,GAC1B,MAAM,IAAIW,MAAOL,EAAO,UAEzB,MAAM,IAAID,UAAWC,EAAQ,QAASN,GACtC,CACD,GAAKL,GAAS,EACb,OAAO,IAAIE,EAAM,GAElB,GAAe,IAAVF,EAEJ,GAAKa,EADLR,EAAMC,UAAW,IAEhBH,EAAM,IAAID,EAAMG,EAAIE,aACd,GAAKQ,EAAeV,GAC1BF,EAAM,IAAID,EAAMG,QACV,GAAKO,EAAsBP,GACjCF,EAAM,IAAID,EAAMG,OACV,KAAKY,EAAUZ,GAarB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAZtC,IAA6B,IAAxBZ,EACJ,MAAM,IAAIiB,UAAWC,EAAQ,QAASN,IAEvC,IAAMa,EAAYb,EAAKc,IACtB,MAAM,IAAIT,UAAWC,EAAQ,QAASN,IAGvC,GADAA,EAAMA,EAAKc,MACLD,EAAYb,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,QAASN,IAEvCF,EAAM,IAAID,EAAMuB,EAAYpB,GAG5B,MAEDF,EADqB,IAAVH,EACL,IAAIE,EAAMI,UAAU,GAAIA,UAAU,IAElC,IAAIJ,EAAMI,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKH,EAAII,OAAS,IACjBR,EAAQO,UAAW,GACdoB,EAAmBzB,GAnM1B,SAA0BE,EAAKJ,GAC9B,IAAI4B,EACJ,IAAMA,EAAI,EAAGA,EAAIxB,EAAII,OAAQoB,IAC5BxB,EAAIyB,IAAK7B,EAAO4B,EAGlB,CA8LGE,CAAiB1B,EAAKJ,GACX+B,EAAmB7B,GAC9B8B,EAAO5B,EAAII,OAAQ,EAAY,EAAI,EAAGyB,EAAiB7B,EAAK,GAAK,GAEjE4B,EAAO5B,EAAII,OAAQR,EAAOI,EAAK,IAG1BA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3ece0cd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,138 +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. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array-filled -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'float16' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array-filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var filledarray = require( '@stdlib/array-filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // 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 dd6bb5b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,290 +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. -*/ - -'use strict'; - -// MODULES // - -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 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 gfill = require( '@stdlib/blas-ext-base-gfill' ); -var filled = require( '@stdlib/array-base-filled' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -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 {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @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 -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float16' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - 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( '00j2Y', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( '00j2a', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( format('00j04') ); - } - throw new TypeError( format( '00j2a', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - 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( '00j2Z', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( '00j2a', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( '00j2a', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/package.json b/package.json index d4823cc..c9e19ae 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a filled array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "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": "^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": "^0.2.3", - "@stdlib/iter-length": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.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-float16": "github:stdlib-js/array-float16#main", - "@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-complex128": "^0.2.3", - "@stdlib/strided-base-reinterpret-complex64": "^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.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..21f460f --- /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 f5d1025..0000000 --- a/test/test.js +++ /dev/null @@ -1,2822 +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'; - -/* eslint-disable max-lines */ - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float16Array = require( '@stdlib/array-float16' ); -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 hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -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', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'Float16', - 'FLOAT64', - 'FLOAT32', - 'FLOAT16', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -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() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'generic' ); - }; - - 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 (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - 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 filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.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 - }; - filledarray( 1.0, obj, 'float64' ); - }; - - 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() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -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() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - 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 = filledarray( '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 = filledarray( '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=float16)', function test( t ) { - var expected; - var arr; - - expected = new Float16Array( 0 ); - - arr = filledarray( 'float16' ); - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.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 = filledarray( '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=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( '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=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( '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=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 = filledarray( '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 arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - 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 (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - 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)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - 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 (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - 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=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - 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 (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - 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=float16, length)', function test( t ) { - var expected; - var arr; - - expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float16' ); - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=float16, length)', function test( t ) { - var expected; - var arr; - - expected = new Float16Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float16' ); - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - 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 (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - 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 (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - 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 (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - 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 arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - 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 (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - 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 arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - 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 (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - 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 arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - 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 (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - 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 arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - 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 (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - 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 arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - 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 (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - 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 arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - 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 (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - 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 arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - 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 (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - 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 arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - 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 (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - 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=float16, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - 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=float16, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - 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=float16, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.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 buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - 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 filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - 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=float16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 2, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - 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 filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - 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=float16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float16Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.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 buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - 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 buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - 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 buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - 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 buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - 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 buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - 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 buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - 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 buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - 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 buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - 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 buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - 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 buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - 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 filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( 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)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - 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=float16, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float16Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float16' ); - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( 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 arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - 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' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - 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 arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - 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 arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - 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 arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - 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 arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - 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 arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - 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 arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - 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 arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - 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 arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - 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 arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - 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 arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - 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(); -});